所以,我一直在尝试添加一个按钮,机器人列表视图下,该问题是按钮不会出现。
< XML版本=1.0编码=UTF-8&GT?;
< AbsoluteLayout
机器人:ID =@ + ID / widget0
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的xmlns:机器人=http://schemas.android.com/apk/res/android>
<的ListView
机器人:ID =@ + ID / MessageList中的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_x =0px
机器人:layout_y =0px>
< / ListView控件>
<按钮
机器人:ID =@ + ID / Add按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=按钮
机器人:layout_x =0px
机器人:layout_y =379px>
< /按钮>
< / AbsoluteLayout>
解决方案
AbsoluteLayout是pcated德$ P $。我建议,而不是你使用的LinearLayout:
< XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
机器人:ID =@ + ID / widget0
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的xmlns:机器人=http://schemas.android.com/apk/res/android>
<的ListView
机器人:ID =@ + ID / MessageList中的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =0dp
机器人:layout_weight =1>
< / ListView控件>
<按钮
机器人:ID =@ + ID / Add按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=按钮>
< /按钮>
< / LinearLayout中>
我也建议通过开发文档阅读布局一个很好的介绍。
So Ive been trying to add a button underneath a listview in android, the problem is that the button does not appear.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/messagelist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="0px">
</ListView>
<Button
android:id="@+id/addbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_x="0px"
android:layout_y="379px">
</Button>
</AbsoluteLayout>
解决方案
AbsoluteLayout is deprecated. I would suggest instead that you use a LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/messagelist"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<Button
android:id="@+id/addbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button">
</Button>
</LinearLayout>
I'd also suggest reading through the developer docs on layouts for a good introduction.