Java android 4.0及更高版本:复制/粘贴/剪切面板仅在EditText上单击Listener时消失
我在选项卡中使用PreferenceActivity,并添加一个带有编辑文本的页脚:Java android 4.0及更高版本:复制/粘贴/剪切面板仅在EditText上单击Listener时消失,java,android,android-edittext,Java,Android,Android Edittext,我在选项卡中使用PreferenceActivity,并添加一个带有编辑文本的页脚: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:foo="http://schemas.android.com/apk/res/com.assignmentexpert"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res/com.assignmentexpert"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="2"
android:stretchColumns="0"
>
<TableRow
android:id="@+id/tableRow1"
style="@style/text_row"
android:layout_weight="1"
>
<com.customitems.CustomEditText
android:id="@+id/taskText"
style="@style/custom_edittext"
android:gravity="top|left"
android:maxLength="8192"
android:layout_marginLeft= "25dp"
android:layout_height="110dp"
android:imeOptions="actionDone"
android:layout_weight="1"
android:layout_width="fill_parent"
android:scrollbars = "vertical"
android:layout_marginRight="10dp"
foo:customFont="Roboto-Regular.ttf"
android:hint="@string/hint_assignment_task"/>
</TableRow>
<TableRow android:layout_height="1px" android:background="#323232">
<TextView android:layout_span="1" android:layout_height="1px"
android:layout_width="fill_parent" android:text="">
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
style="@style/text_row"
android:layout_weight="1"
>
<com.customitems.CustomEditText
android:id="@+id/taskSpecReq"
style="@style/custom_edittext"
android:gravity="top|left"
android:maxLength="8192"
android:layout_marginLeft= "25dp"
android:layout_height="110dp"
android:imeOptions="actionDone"
android:layout_weight="1"
android:layout_width="fill_parent"
android:scrollbars = "vertical"
android:layout_marginRight="10dp"
foo:customFont="Roboto-Regular.ttf"
android:hint="@string/hint_assignment_specific_requirements"/>
</TableRow>
</TableLayout>
</LinearLayout>
因此,当我在taskTest
EditText上使用LongClick时,会显示复制/粘贴/剪切并正常工作。但是当我长时间点击taskSpecReq
mytaskspecreq复制/粘贴/剪切面板时,屏幕上的选项卡消失了。
taskSpecReq
位于屏幕底部
长按第1版文本:
长按第二版文本:
看起来系统可能正在滚动视图,以确保软键盘上方可以看到
CustomEditText
的光标,从而滚动屏幕顶部。检查AndroidManifest.xml
中活动的android:windowSoftInputMode
属性,如所述
(确认是否存在这种情况的一个简单方法是切换两个
CustomEditText
小部件。如果底部的小部件总是出现问题,则可能就是这个问题。)由于我在其中使用了TabHost和嵌套活动,我通过使用
android:windowSoftInputMode="stateUnspecified"
对于TabActivity和嵌套的Activity:
android:windowSoftInputMode = "adjustResize"
它解决了我的问题。@rikkitkitavi使用
adjustPan
不会导致问题吗?我不知道。adjustPan工作良好,可使编辑文本正确聚焦。因为如果没有它,软键盘的动作会很僵硬。