[英]Android Edittext doesnt open keyboard?
在Android應用程序中,默認情況下,單擊或聚焦於edittext時,系統鍵盤會打開。 但是在我的應用中,鍵盤沒有顯示。 為什么呢
布局代碼:
<?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:orientation="vertical"
android:clickable="true"
android:paddingLeft="@dimen/login_padding"
android:paddingRight="@dimen/login_padding"
android:paddingTop="@dimen/login_padding">
<!--<android.support.design.widget.TextInputLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="#fff"-->
<!--android:padding="4dp">-->
<!--</android.support.design.widget.TextInputLayout>-->
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/header_logo"
android:scaleType="fitStart" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/email"
android:nextFocusDown="@+id/password"
android:textIsSelectable="true"
android:inputType="textEmailAddress"/>
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword"
android:textIsSelectable="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register"
android:background="@drawable/buttontype1"
android:textColor="@color/loginScreenButtonTextColor"
android:layout_weight="0.4"
android:layout_marginRight="30dp" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login"
android:background="@drawable/buttontype1"
android:textColor="@color/loginScreenButtonTextColor"
android:layout_weight="0.4" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/forgot_my_password"
android:id="@+id/forgot_password"
android:background="@null"
android:gravity="left"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/information"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
AndroidManifest.xml的某些部分
不要試圖說您使用了android:windowSoftInputMode =“ stateHidden” 。 我使用它是因為它在活動開始時會隱藏鍵盤。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/MyLibrary">
<activity android:name=".main.SplashActivity" android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".login.LoginActivity"
android:label="@string/title_activity_login"
android:windowSoftInputMode="stateHidden"
android:theme="@style/MyLibrary" />
<activity
android:name=".login.RegisterActivity"
android:label="@string/title_activity_forgot_password" />
<activity android:name=".login.ForgotPasswordActivity" />
<activity android:name=".home.HomeActivity" ></activity>
</application>
好。 我解決了我的問題。 我從edittexts中刪除了android:textIsSelectable =“ true” 。 有效
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.