我如何将按钮放在列表下方
how i can place the button below a list
我尝试将按钮放在列表下方,但按钮没有出现。
我用的是RelativeLayout。
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>
我解决了我的问题,删除我按钮中的属性 layout_below
android:layout_below="@+id/Lista"
在我的按钮中添加属性layout_alignParentBottom
android:layout_alignParentBottom="true"
并在我的亲戚@+id/Lista
中添加属性layout_marginBottom
android:layout_marginBottom="50dp"
<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>
你好使用下面的布局你也可以让按钮可见:-
[注意:- 给出此建议的原因是如果您想使用线性布局而不是相对布局,您可以尝试这种方式]
<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" />
谢谢!~!
我尝试将按钮放在列表下方,但按钮没有出现。
我用的是RelativeLayout。
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>
我解决了我的问题,删除我按钮中的属性 layout_below
android:layout_below="@+id/Lista"
在我的按钮中添加属性layout_alignParentBottom
android:layout_alignParentBottom="true"
并在我的亲戚@+id/Lista
中添加属性layout_marginBottomandroid:layout_marginBottom="50dp"
<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>
你好使用下面的布局你也可以让按钮可见:- [注意:- 给出此建议的原因是如果您想使用线性布局而不是相对布局,您可以尝试这种方式]
<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" />
谢谢!~!