Android multi line EditText
I have a multiple line EditText and a submit button below it.
When the user taps on the EditText area, the soft keyboard appears.
It has an enter key on it, which enables the user to move to next line.
My problem is that the soft keyboard hides my submit button - so that when the user finishes editing, he/she has to press the back button on the device to hide the soft keyboard to submit.
Is there any way to keep both enter and done button in the keyboard? Or, is there some other better solution?
Thanks in advance.
是的,您可以使用按钮始终位于页面底部但位于键盘顶部的布局,如此
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_save"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:enabled="false"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="@string/button_save" />
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@+id/button_save"
android:fadeScrollbars="false"
>
...all your stuff here
</ScrollView>
</RelativeLayout>
您还可以在xml布局中设置imeAction
,只要您的editText具有这些事件的侦听器,就可以直接从软键盘调用Done / Next / Search等。
上一篇: 如何使这些按钮功能?
下一篇: Android多行EditText