【问题标题】:Removing suggestion box soft keyboard移除意见箱软键盘
【发布时间】:2018-03-25 19:42:26
【问题描述】:

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

选择密码字段后,一切看起来都很完美,但如果选择的是电子邮件字段,建议框总是会弹出,我无法停止。Image highlighting the exact area I'm talking about

我希望将其删除的原因是因为清单中包含了 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>

【问题讨论】:

  • 您可以为您的布局发布 xml 吗?如果您自动生成布局,可能会有一些自动完成代码。最后,您使用的是自定义键盘吗?
  • android:inputType="textNoSuggestions" 将此添加到电子邮件字段
  • @NileshDeokar 我在电子邮件字段中添加了 android:inputType="textNoSuggestions" ,但这似乎不起作用。不过我很感激这个答案。

标签: android input android-softkeyboard


【解决方案1】:

我能够通过以下方式解决我的问题:

android:inputType="textNoSuggestions|textVisiblePassword"

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2014-06-13
    相关资源
    最近更新 更多