如果您在联系人编辑,如何获取联系人中的保存并取消按钮?
- 保存&取消按钮总是停留在顶部,放置在 虚拟键盘上方。
- 的表单元素滚动
我要实现相同的行为。我有很长的表格可以输入,我想随时让用户保存/取消。
请帮忙。
如果您在联系人编辑,如何获取联系人中的保存并取消按钮?
我要实现相同的行为。我有很长的表格可以输入,我想随时让用户保存/取消。
请帮忙。
你可以做到这一点通过在layout.example添加一个页脚视图:
http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/
我使用此布局实现相同:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:background="#ffffff">
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="50dp">
<Button "></Button>
</RelativeLayout>
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1">
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:background="#ffffff">
<RelativeLayout android:gravity="bottom"
android:paddingTop="40dp" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:background="#ffffff"
android:paddingBottom="55dp">
<Button ></Button>
<Button ></Button>
<Button></Button>
<Button></Button>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<!--for bottom bar -->
<RelativeLayout android:layout_height="50dp"
android:gravity="center" android:layout_width="match_parent"
android:id="@+id/linearLayout2" android:background="#ffffff">
<Button ></Button>
<Button ></Button>
<Button ></Button>
</RelativeLayout>
</LinearLayout>
一个的LinearLayout里面的每一件事情都会符合上述的键盘,这样的设计布局是这样的:
<LinearLayout weightSum="X">
<ScrollView ayout_weight="y" >
....
.....
</ScrollView>
<Layout layout_wieght="z">
<btn save /> <btn cancel />
</layout>
<linearLayout>
试下面的代码,你需要的是主内部布局
1)scrollview,在滚动视图中添加一个包含许多视图的布局。
2)另一种布局,内有2个按钮用于“保存和取消”。并添加样式作为按钮栏。 不要忘记在scrollview中添加weight = 1。
尝试下面的布局,你会得到你想要的。
<?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" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="horizontal|vertical" >
</ScrollView>
//在上面的scrollview中添加您与其他视图的布局。
//下面辣油是按钮栏,只要你想
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/browseAddBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:text="Add" />
<Button
android:id="@+id/browseViewBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:text="Back" />
<Button
android:id="@+id/browseReturnBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
</LinearLayout>
检查我的答案,你会得到你想要的东西.. – AAnkit