android 将面板调整到底部
我的表单上有两个按钮,保存和取消。当我转到表单时,键盘会自动显示。 (顺便说一句。表单有一个 EditText)。我真的不知道如何将按钮安装到底部。现在按钮放置在 EditText 下方,我想将它们放置在键盘上方。
对于想要查看代码的人:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" style="@style/Form">
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="7dp"
android:orientation="vertical">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/etNewListNameForm"
android:hint="list name"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"></EditText>
</LinearLayout>
<LinearLayout style="@style/BottomPanel"
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/btnSaveCardList"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:text="Save"></Button>
<Button
android:id="@+id/btnCancelCardLst"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="Cancel"></Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
最诚挚的问候
图片:
I have a two buttons on my form, save and cancel. When I go to the form, the keyboard shows automatically. (Btw. Form has one EditText). I really dont know how to fit buttons to the bottom. Now buttons are placed below the EditText, I want put them above the keyboard.
For someone who want to see the code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" style="@style/Form">
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="7dp"
android:orientation="vertical">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/etNewListNameForm"
android:hint="list name"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"></EditText>
</LinearLayout>
<LinearLayout style="@style/BottomPanel"
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/btnSaveCardList"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:text="Save"></Button>
<Button
android:id="@+id/btnCancelCardLst"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="Cancel"></Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
best regards
Images:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以选择的一个选择是使用相对布局而不是线性布局,并使用alignParentBottom 属性,如下所示:
编辑:还值得注意的是,您应该非常认真地考虑为视图使用更具描述性的名称。您已经为按钮和 EditText 使用了描述性名称,但仍坚持使用 LinearLayout1 和 LinearLayout2 作为布局视图。考虑将它们命名为 mainLayout、bottomPannelLayout 之类的名称,这样当您尝试弄清楚如何设置它时,会更容易。
One option you have is to use a relative layout instead of linear and use the alignParentBottom attribute, like this:
Edit: It is also worth noting, you should very seriously consider using more descriptive names for your views. You've used descriptive names for your buttons and EditTexts but stuck with linearLayout1, and linearLayout2 for your layout views. Consider naming them something like mainLayout, and bottomPannelLayout or something and it will be easier down the road when you are trying to figure out how you've set it up.
在包含 EditText 的 LinearLayout 中,将
android:layout_height
更改为0dp
并将android:layout_weight
设置为1
。这样,在按钮面板占用其份额后,它将占用父级中的其余空间。In the LinearLayout containing your EditText, change
android:layout_height
to0dp
and setandroid:layout_weight
to1
. That way it will eat up the rest of the space in the parent after the button panel takes its share.删除不必要的视图并使用relativeLayuot
Remove unnecessary views and use relativeLayuot