如何创建在一个ListView一个覆盖布局 [英] How to create a overlay layout upon a listview
问题描述
我有将充满的AsyncTask
A列表视图,并在应用程序的底部边缘,我需要表现出这样一个固定的覆盖布局:
但我无法弄清楚如何,我可以在XML做到这一点? 这是我的present layout.xml:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直>
<的ListView
机器人:ID =@ + ID /列表
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT/>
< - !也许我需要做的东西在这里 - >
< / LinearLayout中>
由于丹尼尔曾建议,使用 RelativeLayout的
,因为它允许部件堆叠(同的FrameLayout
和 SurfaceView
)。下面code会给你你正在寻找的布局:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的ListView
机器人:ID =@ + ID /列表
机器人:layout_width =match_parent
机器人:layout_height =match_parent/>
< RelativeLayout的
机器人:layout_width =match_parent
机器人:layout_height =50dp
机器人:背景=@色/ transparentBlack
机器人:layout_alignParentBottom =真正的>
<的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBottom =@ + ID / textView1
机器人:layout_alignParentRight =真
机器人:layout_marginRight =20dp
机器人:文本=中文字
机器人:文字颜色=@色/白
机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_centerVertical =真
机器人:layout_marginLeft =40dp
机器人:文本=大文本
机器人:textAppearance =机器人:ATTR / textAppearanceLarge
机器人:文字颜色=@色/白/>
< / RelativeLayout的>
< / RelativeLayout的>
在code以上,多用于 transparentBlack
颜色的十六进制值是#9500
和白色
是 #FFFFFF
。
下面是UI设计的基础知识Android的一个很好的教程: Android用户界面设计:布局基础知识。
I have a listview that will be filled with AsyncTask
and at the bottom edge of the app I need to show a fixed overlay layout like this:
But I can't figure it out how I can do this in xml? This is my present layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Probably I need to do something here -->
</LinearLayout>
As Daniel has suggested, use a RelativeLayout
because it allows stacking of components(same with FrameLayout
and SurfaceView
). The following code will give you the layout you are looking for:
<?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" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/transparentBlack"
android:layout_alignParentBottom="true" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:text="Medium Text"
android:textColor="@color/white"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="40dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
In the code above, the color hex values used for transparentBlack
is #95000000
and white
is #ffffff
.
Here is an excellent tutorial on the basics of UI design in android: Android User Interface Design: Layout Basics.
这篇关于如何创建在一个ListView一个覆盖布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!