删除意见箱软键盘

时间:2017-10-13 16:01:09

标签: android input android-softkeyboard

我知道这个问题已被多次询问过。我已经阅读了大部分内容,但仍未找到解决方案。我正在寻找的是一种完全从软键盘中删除建议框的方法。

当选择密码字段时,一切看起来都很完美,但如果选择了电子邮件字段,建议框总会弹出,我无法停止。{{3 }}

我之所以要删除它是因为它改变了我的视图大小,因为我有android:windowSoftInputMode =" adjustResize"包含在清单中。我想在我的登录屏幕上执行此操作,以消除对ScrollView的需求,并在激活软键盘时将所有内容放在易于查找的位置。除了电子邮件字段变为活动状态并显示建议框外,一切正常。然后,当您切换到密码字段时,一切都会再次移动。

非常感谢任何帮助。

activity_emailpassword.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/gradient_background"
tools:context=".activity.auth.EmailPasswordActivity" >

<ImageView
    android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:src="@drawable/login_logo" />

<LinearLayout
    android:id="@+id/LoginBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:orientation="vertical">

    <EditText
        android:id="@+id/email_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:privateImeOptions="nm"
        android:inputType="textNoSuggestions|textWebEmailAddress"
        android:hint="Email ID" />

    <EditText
        android:id="@+id/password_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="30dp"
        android:hint="Password"
        android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom">
    <Button
        android:id="@+id/login_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/colorPrimaryLight"
        android:layout_marginBottom="50dp"
        android:text="Login" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="Create Account"
        android:gravity="bottom"
        android:textColor="@color/colorPrimaryLight"
        android:layout_margin="16dp"
        android:textSize="16sp"
        android:background="@null"
        android:id="@+id/create_account_button" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/forgot_password_button"
    android:layout_alignBaseline="@+id/create_account_button"
    android:layout_alignBottom="@+id/create_account_button"
    android:background="@null"
    android:layout_alignParentEnd="true"
    android:layout_gravity="right"
    android:layout_marginEnd="13dp"
    android:gravity="center"
    android:text="Forgot Password?"
    android:textColor="@color/colorPrimaryLight"
    android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

我能够通过使用:

来解决我的问题

机器人:的inputType = “textNoSuggestions | textVisiblePassword”

不确定它是否是最佳选择,但确实有效。