代码之家  ›  专栏  ›  技术社区  ›  Marcus J.Kennedy

防止关注创建活动

  •  1
  • Marcus J.Kennedy  · 技术社区  · 8 年前

    我需要在活动开始时移除或阻止焦点,我使用了以下代码:

    android:focusableInTouchMode="true"
    
    android:windowSoftInputMode="stateHidden"
    

    但总是在开始的时候,先集中注意力 文本输入布局 没有键盘

    enter image description here

    3 回复  |  直到 8 年前
        1
  •  1
  •   AskNilesh    8 年前

    试试这个

    使用 android:windowSoftInputMode="stateAlwaysHidden" 在清单文件中

    在你的根中使用 ConstraintLayout 布局

    android:focusable="true"
    android:focusableInTouchMode="true"
    

    示例代码

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="vertical"
        android:paddingLeft="16dp"
        android:paddingRight="16dp">
    
        2
  •  0
  •   Itay Feldman    8 年前

    加上-

    <View
        android:layout_width="0px"
        android:layout_height="0px"
        android:focusableInTouchMode="true" />
    

    在编辑文本上方的xml文件中,它将完成这项工作。

        3
  •  -1
  •   Quick learner    8 年前

    试试这个

    添加这些行

    android:focusable=“true” android:focusableInTouchMode=“true”

    以xml格式创建父布局

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="vertical"
        android:paddingLeft="16dp"
        android:paddingRight="16dp">