简体   繁体   English

editText和softkeyboard之间的空间

[英]space between editText and softkeyboard

i have an activity with an editText field almost at the bottom. 我有一个活动,几乎在底部都有一个editText字段。 when i focus on that editText field the keyboard shows up and pushes my edittext field up. 当我专注于那个editText字段时,键盘会出现,并将我的edittext字段向上推。

when it stops there is no space between editText and my softkeyboard. 当它停止时,editText和我的软键盘之间没有空格。

is it possible to add some margin? 有可能增加一些保证金吗?

this is my code: 这是我的代码:

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

position of editText field before keyboard shows up: http://postimg.org/image/826fwy18z/ 键盘出现之前editText字段的位置: http ://postimg.org/image/826fwy18z/

and an image when keyboard is show up, with no space between cursor and keyboard: http://postimg.org/image/97qlfb4zx/ 以及显示键盘时的图像,光标和键盘之间没有空格: http : //postimg.org/image/97qlfb4zx/

You can use android:windowSoftInputMode property of Activity in manifest file. 您可以在清单文件中使用Activity的android:windowSoftInputMode属性。

Use android:windowSoftInputMode= "adjustResize" in your case. 在您的情况下,使用android:windowSoftInputMode = “ adjustResize” You can check other properties as well. 您也可以检查其他属性。

Hope this helps. 希望这可以帮助。

Thanks. 谢谢。

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

android:layout_marginBottom="10dp"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM