android - editText 和软键盘之间的空间

标签 android xml

我有一个 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/

相关文章:

java - Android 使用 Volley 从 HTTP 请求中获取响应

xml - VS2010 中 xsc 和 xss 文件的用途是什么?

android - 有什么方法可以避免 Android XML 布局文件中的 "android:"语句?

c# - 在 XML 模式中引用 C# 类型?

java - 有没有一种方法可以在按下底部的按钮时使按钮不消失?

C# Linq 到 xml。嵌套在父对象中的项目

android - 是否支持 Glonass 卫星?

java - FloatingActionButton 与 RecyclerView 中的 CardView 重叠

显示滚动的 Android 弹出菜单

Android 忽略了 EditText 中的填充