繁体   English   中英

我如何将按钮放在列表下方

[英]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>

您好在下面的布局中使用u,您还可以看到按钮:-[注意:-给出此建议的原因是,如果您要使用linearlayout而不是相对布局,则可以尝试这种方式]

<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" />

谢谢!〜!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM