繁体   English   中英

Android多行EditText

[英]Android multi line EditText

我有一个多行EditText和它下面的提交按钮。
当用户点击EditText区域时,会出现软键盘。
它上面有一个回车键,使用户可以移动到下一行。
我的问题是软键盘隐藏了我的提交按钮 - 这样当用户完成编辑时,他/她必须按设备上的后退按钮来隐藏要提交的软键盘。
有没有办法在键盘上保持输入和完成按钮? 或者,还有其他更好的解决方案吗?

提前致谢。

是的,您可以使用布局,其中按钮始终位于页面底部但位于键盘顶部,类似这样

<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等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM