一个包裹里面的LinearLayout一个ListView [英] Wrapping a ListView inside a LinearLayout
问题描述
我想在顶部,在的ListView
在中间做一个屏幕,的TextView
和一个按钮
在底部。我想它是使的TextView
始终位于屏幕顶部和按钮始终是底部,然后将的ListView
是介于两者之间。当的ListView
超过了中间空间我想滚动功能是只之间的的TextView
和按钮
。随着我尝试它只是扩展超出了的TextView
和按钮
。
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@绘制/纸><的TextView
机器人:ID =@ + ID / tvLOL
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:文字=Standardvarer
机器人:TEXTSIZE =40dp/><的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignTop =@ + ID / tvLOL
机器人:layout_alignBottom =@ + ID / bNyVare
机器人:方向=垂直> < ListView控件
机器人:ID =@机器人:ID /列表
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT/>
< / LinearLayout中><按钮
机器人:ID =@ + ID / bNyVare
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:文字=Tilføj纽约瓦尔
机器人:TEXTSIZE =30dp/>< / RelativeLayout的>
看看这有助于(在的LinearLayout
包裹的ListView
应删除(移动layout_above /下方的的ListView
),如果你只用它来包装的ListView
并没有别的):
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@绘制/纸><的TextView
机器人:ID =@ + ID / tvLOL
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:文字=Standardvarer
机器人:TEXTSIZE =40dp/><按钮
机器人:ID =@ + ID / bNyVare
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:文字=Tilføj纽约瓦尔
机器人:TEXTSIZE =30dp/><的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID / tvLOL
机器人:layout_above =@ ID / bNyVare
机器人:方向=垂直> < ListView控件
机器人:ID =@机器人:ID /列表
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>< / RelativeLayout的>
I'm trying to make a screen with a TextView
at the top, the ListView
in the middle and a Button
at the bottom. I'd like it to be so that the TextView
always is the top at the screen and the button always is the bottom, and then the ListView
is in between. When the ListView
exceeds the "space in the middle" I'd like the scroll-function to be only between the TextView
and Button
. With my attempt it just expands beyond the TextView
and Button
.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/paper" >
<TextView
android:id="@+id/tvLOL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Standardvarer"
android:textSize="40dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvLOL"
android:layout_alignBottom="@+id/bNyVare"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<Button
android:id="@+id/bNyVare"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Tilføj ny vare"
android:textSize="30dp" />
</RelativeLayout>
See if this helps(the LinearLayout
wrapping the ListView
should be removed(and move the layout_above/below to the ListView
) if you only use it to wrap the ListView
and nothing else):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/paper" >
<TextView
android:id="@+id/tvLOL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Standardvarer"
android:textSize="40dp" />
<Button
android:id="@+id/bNyVare"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Tilføj ny vare"
android:textSize="30dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvLOL"
android:layout_above="@id/bNyVare"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
这篇关于一个包裹里面的LinearLayout一个ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!