Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当活动打开时,如何阻止键盘在EditText中弹出?_Android_Android Edittext - Fatal编程技术网

Android 当活动打开时,如何阻止键盘在EditText中弹出?

Android 当活动打开时,如何阻止键盘在EditText中弹出?,android,android-edittext,Android,Android Edittext,我有MainActivity,有EditText和PinView作为用户名和密码。当我打开main时,活动键盘会自动弹出 如何预防 在activit\u main.xml中 <android.support.design.widget.TextInputLayout android:id="@+id/edtEmailLayout" android:layout_width="ma

我有
MainActivity
,有
EditText
PinView
作为用户名和密码。当我打开
main时,活动
键盘会自动弹出

如何预防

activit\u main.xml中

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/edtEmailLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/lblLogin">

                    <EditText
                        android:id="@+id/editText_mobile"
                        style="@style/lato_regular"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/toolbarHeight"
                        android:background="@drawable/edit_bottom_line"
                        android:drawablePadding="8dp"
                        android:gravity="center_vertical"
                        android:hint="@string/mobileNumber"
                        android:inputType="number"
                        android:maxLength="10"
                        android:padding="10dp"
                        android:paddingStart="@dimen/space_with_4dp"
                        android:singleLine="true"
                        android:textColor="@color/black"
                        android:textColorHint="@color/text_hint_color"
                        android:textSize="16sp"
                        />
                </android.support.design.widget.TextInputLayout>
        <activity
        android:name=".module.activity.signin.MainActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateAlwaysHidden">

        <!-- First activity -->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
我还尝试:

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText_mobile.getWindowToken(), 0);


将这两行添加到
EditText

android:focusable="true"
android:focusableInTouchMode="true"
你也可以使用

windowSoftInputMode="stateAlwaysHidden" 

在活动清单@Makarand中,将这两行添加到
EditText

android:focusable="true"
android:focusableInTouchMode="true"
你也可以使用

windowSoftInputMode="stateAlwaysHidden" 

在活动清单@Makarand

中,我正在使用它,它工作得非常好。它不会显示关键字,直到我点击它。。 即使你也应该试试

<com.google.android.material.textfield.TextInputLayout
      android:id="@+id/text1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="16dp">

      <EditText
          android:id="@+id/username"
          style="@style/TextAppearance.AppCompat.Small"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="20dp"
          android:background="@android:color/transparent"
          android:drawableStart="@drawable/email_login"
          android:drawableLeft="@drawable/email_login"
          android:drawablePadding="12dp"
          android:hint="@string/usernameedit"
          android:imeOptions="actionNext"
          android:inputType="text"
          android:maxLength="32"
          android:maxLines="1"
          android:padding="13dp"
          android:textColor="@android:color/black"
          android:textColorHighlight="@android:color/tertiary_text_dark"
          android:textColorHint="@android:color/white" />

     <View
          android:layout_width="match_parent"
          android:layout_height="2dp"
          android:layout_below="@+id/username"
          android:layout_marginLeft="4dp"
          android:layout_marginRight="4dp"
          android:background="#f9d7db" />
</com.google.android.material.textfield.TextInputLayout>

我正在使用它,它工作得非常好。它不会显示关键字,直到我点击它。。 即使你也应该试试

<com.google.android.material.textfield.TextInputLayout
      android:id="@+id/text1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="16dp">

      <EditText
          android:id="@+id/username"
          style="@style/TextAppearance.AppCompat.Small"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="20dp"
          android:background="@android:color/transparent"
          android:drawableStart="@drawable/email_login"
          android:drawableLeft="@drawable/email_login"
          android:drawablePadding="12dp"
          android:hint="@string/usernameedit"
          android:imeOptions="actionNext"
          android:inputType="text"
          android:maxLength="32"
          android:maxLines="1"
          android:padding="13dp"
          android:textColor="@android:color/black"
          android:textColorHighlight="@android:color/tertiary_text_dark"
          android:textColorHint="@android:color/white" />

     <View
          android:layout_width="match_parent"
          android:layout_height="2dp"
          android:layout_below="@+id/username"
          android:layout_marginLeft="4dp"
          android:layout_marginRight="4dp"
          android:background="#f9d7db" />
</com.google.android.material.textfield.TextInputLayout>

在XML布局的根视图中添加这两行

i、 e.根视图可以是ContrainLayout或任何其他布局

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" 

在XML布局的根视图中添加这两行

i、 e.根视图可以是ContrainLayout或任何其他布局

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" 

您是否已检查此项:
android:windowsofInputMode=“stateHidden”
yes,但@nileshrate不起作用请检查此项:将android:focusableInTouchMode=“true”添加到编辑文本的父布局中。希望此项将帮助您:是否已检查此项:
android:windowsofInputMode=“stateHidden”
yes,但是@nileshrathodp不起作用请检查以下内容:将android:focusableInTouchMode=“true”添加到编辑文本的父布局中。希望这能帮助您: