键盘在焦点上阻止屏幕

时间:2017-03-10 09:13:10

标签: android android-edittext android-softkeyboard

我有一个包含3个EditTexts的片段,触摸时应该可以专注。

单击EditText时,我需要显示所有EditTexts。这意味着当我单击EditText 1时,EditText 3应该是可见的。所以基本上每个EditText都应该始终可见。

现在,当我点击EditText片段移位时,仍会阻止EditText编号为3。

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="6"
android:orientation="horizontal">

<View
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1" />

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="4"
    android:orientation="vertical">

    <EditText
        android:id="@+id/et_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/apptheme_textfield_white_holo_no_borders_light"
        android:gravity="center"
        android:hint="@string/username_tag"
        android:imeOptions="flagNoExtractUi|actionNext"
        android:inputType="text"
        android:maxLines="1"
        android:textColor="@android:color/white"
        android:textColorHint="@color/gray_lighter"
        android:textCursorDrawable="@null" />

    <EditText
        android:id="@+id/et_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
            android:background="@drawable/apptheme_textfield_white_holo_no_borders_light"
        android:drawablePadding="5dp"
        android:drawableStart="@drawable/profile_pressed"
        android:gravity="center"
        android:hint="@string/email_tag"
        android:imeOptions="flagNoExtractUi|actionNext"
        android:inputType="textEmailAddress"
        android:maxLines="1"
        android:textColor="@android:color/white"
        android:textColorHint="@color/gray_lighter"
        android:textCursorDrawable="@null" />

    <EditText
        android:id="@+id/et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/apptheme_textfield_white_holo_no_borders_light"
        android:drawablePadding="5dp"
        android:drawableStart="@drawable/padlock"
        android:gravity="center"
        android:hint="@string/password"
        android:imeOptions="flagNoExtractUi|actionDone"
        android:inputType="textPassword"
        android:maxLines="1"
        android:textColor="@android:color/white"
        android:textColorHint="@color/gray_lighter"
        android:textCursorDrawable="@null" />

</LinearLayout>

<View
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1" />

</LinearLayout>

我尝试在清单中搞乱adjustPan和adjustResize,但两者都不起作用。

这是图片:

enter image description here

请注意,带密码输入的EditText 3会被键盘阻止。

1 个答案:

答案 0 :(得分:0)

在您宣布活动的代码中的清单中添加以下属性:

windowSoftInputMode="adjustResize"

并将您的布局置于滚动视图中

相关问题