2011-06-14 5 views
0

대화 상자에 ListView가 있으며 목록 뒤에 버튼을 표시해야합니다.아래의 버튼이 제대로 작동하지 않는 목록보기

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="wrap_content"> 
<TextView android:id="@+id/tvwGameOver" android:layout_weight="1" android:gravity="center" 
      android:textSize="25sp" android:visibility="gone" 
      android:layout_width="fill_parent" android:layout_height="wrap_content"/> 
<LinearLayout 
    android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:orientation="horizontal" android:footerDividersEnabled="true" 
    android:headerDividersEnabled="true" android:layout_below="@id/tvwGameOver"> 
    <TextView 
    android:id="@+id/tvwGameNumberHeader" android:layout_weight="1" android:gravity="right" 
    android:text="@string/scores_GameNumber" android:textSize="12sp" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_marginRight="13sp"/> 
    <TextView 
    android:id="@+id/tvwPlayer0Name" android:layout_weight="1" android:gravity="right" 
    android:textSize="12sp" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_marginRight="13sp"/> 
    <TextView 
    android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right" 
    android:textSize="12sp" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_marginRight="13sp"/> 
    <TextView  
    android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right" 
    android:textSize="12sp" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_marginRight="13sp"/> 
    <TextView  
    android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right" 
    android:textSize="12sp" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_marginRight="13sp"/> 
</LinearLayout> 


    <ListView 
    android:id="@+id/lvwScores" android:layout_below="@id/lloPlayerNames" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:divider="#FFFFFF" android:dividerHeight="1dip" 
    android:layout_weight="1" 
    android:footerDividersEnabled="true" android:headerDividersEnabled ="true"/> 

<Button android:id="@+id/btnOK" 
    android:layout_height="wrap_content" android:layout_width="120dip" 
    android:layout_weight="1" 
    android:text="OK" android:layout_centerHorizontal="true" 
android:layout_alignParentBottom="true" 

    /> 
</RelativeLayout> 

목록이 너무 커지면 버튼을 통과하고 버튼이 목록의 맨 위에 위치한다는 문제가 있습니다.

android : layout_below = "@ id/lvwScores"를 버튼에 추가하려고했지만 목록이 비어 있으면 화면 하단에서 목록 하단까지 버튼이 생깁니다.

android : layout_alignParentBottom = "true"를 제거하면 대화 상자가 작아집니다.

하루가 끝날 때, 하단에 버튼이있는 채로 화면의 일부가 여전히 비어 있어도 (점수 화면), 대부분의 화면을 채우려합니다.

아이디어가 있으십니까?

이 그것을 할 때 빈 모습입니다 : 목록이 축적 아래 버튼에서 중지되지 않는 바닥에 도달 할 때 enter image description here

그것은 것을 제외하고 중대하다.

+0

RelativeLayout의 요점은 무엇입니까? 하단에 항상 버튼이 있습니까? 왜 LinearLayout을 사용하고 ListView에 1의 가중치를 부여하지 않는가? – dmon

답변

1

어쩌면 목록보기 또는 목록보기의 컨테이너 하단에 단추의 높이 여백을 줄 수 있습니까? 테스트와 마찬가지로 버튼에 30 dips 높이를 지정하고 listview 또는 listview의 컨테이너에 30 dips의 하단 여백을 지정하여 버튼 뒤쪽에서 계속 실행되는지 확인합니다.

+0

한번 시도해 보겠습니다. 그렇게하는 데 몇 분이 걸릴 것입니다. – theblitz

+0

완벽한! 많은 감사합니다! – theblitz

+0

서비스의 기쁜 소식 –

0

버튼은 android:layout_below="@id/lvwScores"

alignParentBottom가 fill_parent하지 않는 RelativeLayouts위한 가장 좋은 방법 아니다 있어야합니다.

+0

문제는 목록이 비어있는 경우에도 대화 상자를 채우고 싶습니다. 편집을 참조하십시오. – theblitz

관련 문제