EditText和软键盘之间的空格

9

我有一个带有一个EditText字段的活动,几乎在底部。

当我聚焦于该EditText字段时,键盘会弹出并将我的EditText字段向上推。

当它停下来时,EditText和我的软键盘之间没有空间。

是否可以添加一些边距?

这是我的代码:

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


Jan,你能上传一张截图吗?我不理解这个问题。 - Yauraw Gadav
我已经尝试过了,但是声望点数不够:(还有其他方法吗? - Jan Verhagen
已经上传了图片 :) - Jan Verhagen
你找到答案了吗?我也有同样的问题。 - Ashkan
2个回答

1
您可以在清单文件中的 Activity 中使用android:windowSoftInputMode 属性。在您的情况下,请使用 android:windowSoftInputMode="adjustResize"。您也可以查看其他属性。
希望这可以帮到您。
谢谢。

-1

在编辑文本字段底部添加边距

android:layout_marginBottom="10dp"

我之前尝试过,但它对空间没有任何影响。 - Jan Verhagen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接