我知道這個問題已被多次詢問。我已經閱讀了他們中的大多數,但仍然沒有找到解決方案。我正在尋找的是一種完全從軟鍵盤刪除建議框的方法。刪除意見箱軟鍵盤
當選擇密碼字段時,一切都看起來很完美,但如果是選中的電子郵件字段,則建議框總會彈出,我無法停止。 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」,但這似乎不起作用。雖然我很欣賞答案。 – mlewis27