[英]how to add a relative layout inside a listview in transparent to the bottom of the listview
I have a list view in my app and to the bottom of the list view i need to add to buttons but it should be above that the listview with less colored transparent background 我的应用程序中有一个列表视图,在列表视图的底部,我需要添加到按钮中,但是它应该位于具有较少彩色透明背景的列表视图之上
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" >
</ListView>
</LinearLayout>
You can use a RelativeLayout
instead of LinearLayout
to render the buttons on top on the list. 您可以使用RelativeLayout
而不是LinearLayout
来呈现列表顶部的按钮。 I also suggest using android:layout_above="@+id/your_button"
on your listview
so that you don't block any elements. 我还建议在listview
上使用android:layout_above="@+id/your_button"
,以免阻塞任何元素。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1" />
</LinearLayout>
</RelativeLayout>
this is work for you :) 这是为你工作:)
This will work well for you, I guess: 我想这对您来说很好用:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/llbutton"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" >
</ListView>
<LinearLayout
android:id="@+id/llbutton"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 2"
/>
</LinearLayout>
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.