2015-11-25 62 views
0

我嘗試將按鈕放置在列表下方,但不顯示按鈕。如何將按鈕放置在列表下方

我使用RelativeLayout。

enter image description here

activity_main.xml中

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/Lista" 
     > 
     <ListView 
      android:id="@+id/listFotMultas" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 
    </RelativeLayout> 
      <Button 
       android:layout_below="@+id/Lista" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:text="Total Fotomulta" 
       android:layout_marginLeft="25dp" 
       android:layout_marginRight="25dp" 
       android:background="@drawable/estilo_redondoboton" 
       /> 
    </RelativeLayout> 

回答

0

我解決我的問題,在我的按鈕刪除屬性layout_below

android:layout_below="@+id/Lista" 

添加的屬性在我的按鈕layout_alignParentBo TTOM

android:layout_alignParentBottom="true" 

並添加屬性layout_marginBottom在我的親戚@ + ID /利斯塔

android:layout_marginBottom="50dp" 

enter image description here

<RelativeLayout 
     android:layout_below="@+id/ListaEncabezado" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="50dp" 
     android:id="@+id/Lista" 
     > 
     <ListView 
      android:id="@+id/listFotMultas" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      > 
     </ListView> 
    </RelativeLayout> 

      <Button 

       android:layout_width="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:text="Total Fotomulta" 
       android:layout_marginLeft="25dp" 
       android:layout_marginRight="25dp" 
       android:background="@drawable/estilo_redondoboton" 
       /> 

    </RelativeLayout> 
0

你好使用下面的佈局ü還可以有按鈕可見: - [注意: - 如果你想使用線性層,給出這個建議的原因出,而不是相對佈局的你可以試試這個方法]

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


<ListView 
    android:id="@+id/listFotMultas" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" /> 

<Button 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_marginLeft="25dp" 
    android:layout_marginRight="25dp" 
    android:text="Total Fotomulta" /> 

謝謝!〜!

相關問題