2012-08-26 11 views
6

Android 기기 용 앱을 만들고 LinearLayout 내부에 ScrollView를 갖기 위해 노력하고 있지만이 작업을 시도하면 ScrollView가 ScrollView 이후의 모든 공간과 요소를 차지합니다. LinearLayout 사라짐 예를 들어Android : ScrollView in vertical LinearLayout

:
있는 ScrollView 경우는 없다 "전체"입니다 :
http://kakko76.free.fr/scroll2.jpg
있는 ScrollView는 "전체"인 경우 :
http://kakko76.free.fr/scroll1.png

당신이 ... 버튼 사라지는을 볼 수 있듯이

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_marginLeft="50dp" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:orientation="vertical" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:background="@drawable/linearlayoutbackground" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/nom_des_joueurs" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_marginBottom="30dp" /> 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:id="@+id/llPlayersName" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 

     </LinearLayout> 

    </ScrollView> 

    <Button 
     android:id="@+id/okPlayersName" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/ok" 
     android:background="@drawable/backgroundbutton" 
     android:layout_marginTop="30dp" /> 
</LinearLayout> 

나는 원격 교육의 요소를 추가 한 후 : 다음은이 활동의 ​​코드는 ScrollView에있는 rLayout.
모든 솔루션?
감사합니다.

답변

9

는 다음을 시도해보십시오이 다른 요소들에 의해 점유 된 모든 나머지 공간을 위해있는 ScrollView를 알려줍니다

android:layout_height="0dp" 
android:layout_weight="1" 

.

+1

동일한 해결책을 동시에 작성했는데 :-p 당신은 더 빨랐습니다. –

+0

고맙습니다. :) – kakko76

1

귀하의 신장은 android:layout_height="wrap_content"입니다. 이는 높이가 내부의 내용만큼 높다는 것을 의미합니다. 만약 당신이 그것을 가지고 싶지 않다면 당신은 무게를 줄 수 있습니다 (위의 답과 같습니다) 또는 dp로 당신의 hight를 설정할 수 있습니다. 예를 들면 : 당신이 볼 수있는

<LinearLayout 
android:id="@+id/linearLayout1" 
android:layout_width="fill_parent" 
android:layout_marginLeft="50dp" 
android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" 
android:layout_centerVertical="true" 
android:orientation="vertical" 
android:focusable="true" 
android:focusableInTouchMode="true" 
android:background="@drawable/linearlayoutbackground" 
android:weightSum="1.5" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:layout_weight = "0.2" 
    android:text="@string/nom_des_joueurs" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:layout_marginBottom="30dp" /> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight = "1"> 

    <LinearLayout 
     android:id="@+id/llPlayersName" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     > 

    </LinearLayout> 

</ScrollView> 

<Button 
    android:id="@+id/okPlayersName" 
    android:layout_width="match_parent" 
    android:layout_height="0" 
    android:layout_weight = "0.3"> 
    android:text="@string/ok" 
    android:background="@drawable/backgroundbutton" 
    android:layout_marginTop="30dp" /> 

난은 "합계"와 그의 아이들의 모든 주어진 무게 선형 레이아웃을했다. 분명합니까? 그게 니가 필요한거야?