2017-10-13 95 views
0

我知道这个问题已被多次询问。我已经阅读了他们中的大多数,但仍然没有找到解决方案。我正在寻找的是一种完全从软键盘删除建议框的方法。删除意见箱软键盘

当选择密码字段时,一切都看起来很完美,但如果是选中的电子邮件字段,则建议框总会弹出,我无法停止。 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> 
+0

你可以发布你的布局的XML?如果您自动生成布局,则可能会有一些自动完成代码。最后,你在使用自定义键盘吗? –

+0

'android:inputType =“textNoSuggestions”'将此项添加到电子邮件字段 –

+0

@NileshDeokar我在电子邮件字段中添加了android:inputType =“textNoSuggestions”,但这似乎不起作用。虽然我很欣赏答案。 – mlewis27

回答

0

我能够通过使用来解决我的问题:

安卓的inputType = “textNoSuggestions | textVisiblePassword”

不知道这是否是最好的选择,但它确实有效。