当前位置: 代码迷 >> Android >> listview旋钮的位置
  详细解决方案

listview旋钮的位置

热度:36   发布时间:2016-05-01 15:07:34.0
listview按钮的位置
我实现了一个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>


------解决方案--------------------
XML code
<?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>
  相关解决方案