[英]soft keyboard hides my edittext - android
我的布局中有一个编辑文本,但是单击此编辑文本后,软键盘会出现,并覆盖整个文本字段。 结果,我看不到我在输入什么,这很烦人。 谁能告诉我是否有解决方法?
编辑:我还试图将整个布局包装在滚动视图中。 我以这种方式听说可以得到想要的东西,但仍然没有任何反应。 这是我的布局代码:
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="@+id/mainLayoutMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" >
.................... Bunch of View....................
</RelativeLayout>
</ScrollView>
我还可以做些什么?
PS我也尝试在清单文件中设置以下属性:
android:windowSoftInputMode="adjustPan"
和:
android:windowSoftInputMode="adjustResize"
乃至:
android:windowSoftInputMode="adjustPan|adjustResize"
但是什么都行不通。 一切都会导致相同的结果-软键盘隐藏了编辑文本字段。
您可以做的一件事是使您的根(父)布局具有android:layout_height="wrap_content"
,这样,在召唤软键盘时, View
将自身失效,并相应地调整大小,并且如果EditText
对齐此View
底部(出于这个原因,我建议您将RelativeLayout
用作父级,它也会提高。
编辑:
另一件事:
尝试将此属性设置到清单中:
<application ... >
<activity
android:windowSoftInputMode="adjustResize" ... >
...
</activity>
...
</application>
然后更改您的根目录布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@drawable/background_grey"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<!-- Your Layout content here -->
</RelativeLayout>
</ScrollView>
我不知道任何其他解决方案,这主要是由于没有已知的回调或某种事件来处理代码中的此类行为(软键盘生成)。
因此,一切都取决于布局设计和属性,以及android系统如何根据此处理Input事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.