我有一个 editText 字段几乎在底部的 Activity 。 当我专注于那个 editText 字段时,键盘会出现并将我的 edittext 字段向上推。
当它停止时,editText 和我的软键盘之间没有空格。
是否可以增加一些 margin ?
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_yellow"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:paddingTop="25dp"
>
<RelativeLayout
android:layout_width="340dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
>
<EditText
android:layout_width="340dp"
android:layout_height="45dp"
android:background="@drawable/edit_text_field"
android:inputType="text"
/>
</RelativeLayout>
</RelativeLayout>
键盘出现前 editText 字段的位置: http://postimg.org/image/826fwy18z/
和键盘显示时的图像,光标和键盘之间没有空格: http://postimg.org/image/97qlfb4zx/
最佳答案
您可以使用 android:windowSoftInputMode list 文件中 Activity 的属性。
在您的情况下使用 android:windowSoftInputMode="adjustResize"。您也可以检查其他属性。
希望这对您有所帮助。
谢谢。
关于android - editText 和软键盘之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20010187/