【问题标题】:Android multi line EditTextAndroid多行EditText
【发布时间】:2012-07-18 12:04:33
【问题描述】:

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

提前致谢。

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      您还可以在 xml 布局中设置 imeAction,只要您的 editText 具有这些事件的侦听器,您就可以直接从软键盘调用 Done/Next/Search 等。

      【讨论】:

        猜你喜欢
        • 2016-03-29
        • 2013-06-13
        • 2017-07-09
        • 2013-08-09
        • 2013-01-12
        • 1970-01-01
        • 2020-03-07
        • 2011-09-27
        • 2012-07-29
        相关资源
        最近更新 更多