点按EditText后,Android不会仅在某些设备上显示键盘

时间:2017-06-20 16:19:48

标签: android android-edittext manifest textinputlayout

当某些(并非所有)用户点击EditText时会发生奇怪的事情。

键盘不会出现。

布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:focusableInTouchMode="true">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/estra" />

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color" />

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@color/trasparent"
android:gravity="center"
android:navigationIcon="@drawable/back_normal"
android:textAlignment="center"
foo:layout_collapseMode="pin">

<it.estraspa.areaclienti.utilities.ui.TextViewEstra
android:id="@+id/toolbar_title" 
android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center_horizontal"
    android:text="@string/accedi"
    android:textColor="@color/white"
    android:textSize="18sp"
    foo:Overpass="bold" />

</android.support.v7.widget.Toolbar>


<LinearLayout
    android:id="@+id/ll_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_below="@id/toolbar"
    android:layout_centerVertical="true"
    android:layout_marginTop="20dp"
    android:orientation="vertical">

    <it.estraspa.areaclienti.utilities.ui.TextViewEstra
        android:id="@+id/tv_login_error"
        android:layout_width="match_parent"
        android:layout_height="32dp"
        android:layout_marginBottom="@dimen/small_margin"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="50dp"
        android:background="@drawable/custom_error_shape"
        android:drawableLeft="@drawable/icon_error_msg"
        android:drawablePadding="@dimen/normal_margin"
        android:paddingStart="@dimen/normal_margin"
        android:paddingTop="5dp"
        android:text=""
        android:textColor="@color/white"
        android:textSize="@dimen/text_25px_sp13"
        android:visibility="invisible"
        foo:Overpass="light" />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/til_codice_cliente"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/small_margin"
        android:textColorHint="@color/white">

        <it.estraspa.areaclienti.utilities.ui.EditTextEstra
            android:id="@+id/et_codice_cliente"
            style="@style/SingleLineText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="25dp"
            android:backgroundTint="@color/white"
            android:hint="@string/nome_utente"
            android:inputType="text"
            android:minHeight="50dp"
            android:textColor="@color/white"
            android:textColorHighlight="@color/white"
            android:textColorHint="@color/white"
            android:textSize="@dimen/text_size_37px_18dp"
            foo:Overpass2="regular" />

    </android.support.design.widget.TextInputLayout>


    <android.support.design.widget.TextInputLayout
        android:id="@+id/til_codice_fiscale"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColorHint="@color/white"
        foo:passwordToggleEnabled="true"
        foo:passwordToggleTint="@color/white">

        <it.estraspa.areaclienti.utilities.ui.EditTextEstra
            android:id="@+id/et_codice_fiscale"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="@dimen/small_margin"
            android:backgroundTint="@color/white"
            android:hint="@string/password"
            android:inputType="textPassword"
            android:maxLines="1"
            android:minHeight="50dp"
            android:textColor="@color/white"
            android:textColorHint="@color/white"
            android:textSize="@dimen/text_size_37px_18dp"
            foo:Overpass2="regular"

            />
    </android.support.design.widget.TextInputLayout>


</LinearLayout>


<LinearLayout
    android:id="@+id/ll_text2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/ll_text"
    android:layout_marginTop="20dp"
    android:orientation="vertical">


    <it.estraspa.areaclienti.utilities.ui.ButtonEstra
        android:id="@+id/bt_accedi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignStart="@+id/bt_registrati"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:background="@drawable/custom_button_on_blu_background"
        android:clickable="true"
        android:minHeight="50dip"
        android:minWidth="285dp"
        android:text="@string/accedi"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="@dimen/size_16sp_31_px"
        foo:Overpass3="bold" />

    <it.estraspa.areaclienti.utilities.ui.TextViewEstra
        android:id="@+id/tvForgotPassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:clickable="true"
        android:elevation="16dp"
        android:gravity="center"
        android:text="@string/password_dimenticata"
        android:textColor="@color/white"
        android:textSize="@dimen/text_14sp_27px"
        foo:Overpass="bold" />


    <ImageView
        android:id="@+id/tvnoaccount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/ll_text2"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="60dp"
        android:src="@drawable/text_no_account"
        android:visibility="gone" />

    <it.estraspa.areaclienti.utilities.ui.ButtonEstra
        android:id="@+id/bt_registrati"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/tvnoaccount"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="20dp"
        android:background="@drawable/custom_button_transparent"
        android:clickable="true"
        android:minHeight="50dip"
        android:minWidth="285dp"
        android:text="@string/registrati"
        android:textColor="@color/white"
        android:textSize="@dimen/size_16sp_31_px"
        android:visibility="gone"
        foo:Overpass3="bold" />
</LinearLayout>


</RelativeLayout>

我的清单

<activity
        android:name=".presentationlayer.activities.LoginActivity"
        android:screenOrientation="portrait"
        android:theme="@style/EstraStyle"
        android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
/>

如果我从清单中删除此行       机器人:windowSoftInputMode =&#34; stateAlwaysHidden | adjustPan&#34;

键盘可以在所有设备上正常工作吗? 我无法重现这种情况,因为我没有特定的设备。

1 个答案:

答案 0 :(得分:1)

删除stateAlwaysHidden。它告诉操作系统不要在此活动中显示键盘,除非明确显示。