listview按钮的位置

zhang422173651 2012-08-20 10:14:23
我实现了一个listview点击按钮add就新增一行,但是add在下方一直增加的话add会被屏幕覆盖,现在我想将它移动到顶部固定的地方,该如何实现。


贴个我的布局文件
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/i2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:focusable="false" />

<ImageView
android:id="@+id/i3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="1200dp"
android:focusable="false" />

<EditText
android:id="@+id/e1"
android:layout_width="300dp"
android:layout_height="50dp"
android:textColor="#000000"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50dp"
android:background="#eeffee"
/>

<!-- <TextView
android:id="@+id/t2"
android:layout_width="500dp"
android:layout_height="50dp"
android:textCoror="#000000"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50dp"
android:background="#eeffee"

/>-->

</RelativeLayout>
test4.xml
<?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"
android:background="@drawable/fj"
>




<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新增"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:textColor="#000000"
android:background="#eeff00"
>



</Button>



</LinearLayout>
...全文
146 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
seener_wal 2012-08-20
  • 打赏
  • 举报
回复
直接做自动加载不就完事了
AMinfo 2012-08-20
  • 打赏
  • 举报
回复

<?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"
android:background="@drawable/fj"
>


<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新增"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:textColor="#000000"
android:background="#eeff00"
>



</Button>


<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>





</LinearLayout>
zhang422173651 2012-08-20
  • 打赏
  • 举报
回复
改一下位置就成了,开始有异常以为不可以换位置,改了之后就可以了

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧