2013-04-24 5 views
7

ScrollView 안에 목록이있는 대화 상자 (TextViewLinearLayout 안에 있음)가 있습니다. 다음과 같이 레이아웃은 다음과 같습니다Scrollview가 아래쪽보기를 사라지게합니다.

그것은 목록에 몇 항목과 같습니다
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ProgressBar 
     android:id="@+id/delete_progress" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:visibility="gone" /> 

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

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

    <View 
     android:id="@+id/horisontal_separator" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/darker_gray" /> 

    <LinearLayout 
     android:id="@+id/button_container" 
     android:layout_width="match_parent" 
     android:layout_height="48dp" > 

     <Button 
      android:id="@+id/load_button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="@string/button_load" 
      android:gravity="center" 
      android:layout_weight="1" /> 

     <View 
      android:layout_width="1dp" 
      android:layout_height="fill_parent" 
      android:background="@android:color/darker_gray" /> 

     <Button 
      android:id="@+id/delete_button" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="@string/button_delete" 
      android:gravity="center" 
      android:layout_weight="1" /> 
    </LinearLayout> 

</LinearLayout> 

: A few items on the list

그러나 화면에 표시 할 수있는 것보다 더 많은 것이있다 (그리고 스크롤 실제 필요가있을 때) 내 단추가 화면 아래로 밀려납니다. 바닥에 모든 방법을 스크롤 할 때, 다음과 같습니다 : A lot of items on the list

내가 바닥 글로 유지하기 위해 버튼을 포함하는 LinearLayout, 그것은 어디 스크롤되지 분명히 사라지지해야합니다. 나는 레이아웃 높이와 무게로 부지런히 노력했지만 아무 소용이 없습니다.

+0

ListView를 고정 된 높이 (예 : 200dip)로 설정하려고 시도 했습니까? – Demonick

+0

실제'ListView'가 없지만'LinearLayout'의 높이를 변경해도 차이가 없습니다. 그리고'ScrollView'의 높이를 변경하면 버튼이 다시 튀어 나오게됩니다. – j0ntech

답변

19

난 당신이 명시 적으로 그런

<ScrollView 
    android:id="@+id/filename_scroll" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > ////say android:layout_height="50dp" 

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

같이있는 ScrollView의 layout_height를 언급해야한다고 생각있는 ScrollView

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

이것은 완벽하게 작동합니다. 왜 그리고 어떻게 일어나고 있는지 설명해 주시겠습니까? –

+0

이것은 나를 위해 일했습니다! 왜 이것이 효과가 있는지에 대한 설명을 좋아할 것입니다. – Vinnie

0

에 변경하려고합니다. 또 다른 옵션은 layout_height를 명시 적으로 지정하여 테이블 레이아웃과 같은 외부 컴포넌트를 소개하고 스크롤 뷰를 그대로 포함하는 것입니다.

<FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ListView 
     android:id="@+id/gameList" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="30dip" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" > 

     <Button 
      android:id="@+id/load" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Load" /> 

     <Button 
      android:id="@+id/delete" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Delete" /> 
    </LinearLayout> 
</FrameLayout> 

, 그것은 표시 할 사용자 정의 대화 상자의 XML 레이아웃 아래

+0

목록에있는 항목의 수에 따라 크기가 변경되므로 명시 적으로 지정하고 싶지 않습니다. 어쨌든, umesh의 대답은 제가 필요로했던 것과 정확히 같습니다. – j0ntech

+0

그게 나를 위해 작동합니다. 스크롤 뷰는 컨테이너로 작동하며 동적 콘텐츠를 사용하고 있습니다. 20nos 이상. 어쨌든, 다행 이네요. –

0

사용을 작동 희망과에서 다음과 같이 호출하여 클래스 파일

>  Button getList = (Button) findViewById(R.id.getList); 
>  getList.setOnClickListener(new View.OnClickListener() { 
>  
>    @Override 
>  public void onClick(View v) { 
>  // TODO Auto-generated method stub 
>  final Dialog listDialog = new Dialog(MainActivity.this); 
>  listDialog.setTitle("Load a game"); 
>  listDialog.setContentView(R.layout.custom_dialog); 
>  
>  ListView gameList = (ListView) listDialog.findViewById(R.id.gameList); 
>  gameList.setAdapter(new ArrayAdapter<String>   (MainActivity.this,android.R.layout.simple_list_item_1,new String[] {"your array" })); 
>  
>  Button dismiss = (Button) listDialog.findViewById(R.id.load); 
>  dismiss.setOnClickListener(new View.OnClickListener() { 
>  
>   @Override 
>   public void onClick(View v) { 
>    // TODO Auto-generated method stub 
>    listDialog.dismiss(); 
>      } 
>   }); 
>  
>   listDialog.show(); 
>  
>   } }); 
+0

그'marginBottom' 물건은 꽤 똑똑하지만, 이미 답을 얻었습니다. 또한 원래의 레이아웃에는 ListView가 없었습니다. 너는 그 질문을 읽었 니? – j0ntech

+0

안녕하세요 jOntech, 나는 이미 그것을 읽고 당신을위한 대체 솔루션을 제안합니다. 그리고이 샘플은 당신의 목적에 부합하고 샘플을 실행하고 있습니다. 확인해 봤어? –

관련 문제