2014-10-19 116 views
0

如何讓內容填滿整個屏幕而不管屏幕尺寸如何?如何讓內容填滿整個屏幕?

圖片顯示在下方。 我希望它看起來像左邊的圖像,像正確的:

enter image description hereenter image description here

+0

這是什麼,listview還是什麼? – 2014-10-19 12:45:42

+0

這是相對的佈局,有3個textview和6個按鈕 – Soiks 2014-10-19 12:49:16

+1

把所有這個視圖放在一個Realative Layout中,並使其高度,寬度如下android:layout_width =「fill_parent」android:layout_height =「fill_parent」 – 2014-10-19 12:56:11

回答

0

如果你使用的RelativeLayout您可以將容器改變的LinearLayout和layout_weight設置爲它的孩子們:

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="Text 1"/> 

    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="Text 2"/> 

</LinearLayout> 
0

讓我們考慮你的XML文件

創建內部RelativeLayout並將其寬度和高度設置爲match_parent

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" > 
<!-- here you create your RelativeLayout --> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <EditText 
     android:id="@+id/name" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:hint="@string/reminder" /> 
    <TextView 
     android:id="@+id/dates" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/name" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="@+id/times" /> 
    <TextView 
     android:id="@id/times" 
     android:layout_width="96dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/name" 
     android:layout_alignParentRight="true" /> 
    <Button 
     android:layout_width="96dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/times" 
     android:layout_centerInParent="true" 
     android:text="@string/done" /> 

<!-- here close of your created RelativeLayout --> 
</RelativeLayout> 


</RelativeLayout>