阻止 Decimal EditText 获得对启动的关注
Stop Decimal EditText from gaining focus on startup
我有 followed this solution 防止编辑文本聚焦于 activity 启动。并如此实施
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/amount"
android:text="@string/zero"
android:gravity="end|center_vertical"
android:nextFocusUp="@id/amount"
android:nextFocusLeft="@id/amount"
android:inputType="numberDecimal"/>
注意 android:inputType="numberDecimal"
。如果我删除它,那么在启动时焦点不会被占用,但是如果它在那里,那么焦点就会被占用。有没有办法让十进制编辑文本在启动时不关注?如果有任何问题,我正在使用 API > 23。
正如在查看其他人对类似问题提供的答案时的旁注一样,我希望我的领域不会受到关注。我不想只隐藏软键盘而保持焦点。
将此添加到 manifest
中的 activity
标签
android:windowSoftInputMode="stateHidden|adjustResize"
代码类似于清单
<activity
android:name=".ActivityName"
android:windowSoftInputMode="stateHidden|adjustResize" />
This will help hide soft keyboard at startup
并将这些标签添加到您的根布局而不是父布局
android:focusable="true"
android:focusableInTouchMode="true"
我有 followed this solution 防止编辑文本聚焦于 activity 启动。并如此实施
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/amount"
android:text="@string/zero"
android:gravity="end|center_vertical"
android:nextFocusUp="@id/amount"
android:nextFocusLeft="@id/amount"
android:inputType="numberDecimal"/>
注意 android:inputType="numberDecimal"
。如果我删除它,那么在启动时焦点不会被占用,但是如果它在那里,那么焦点就会被占用。有没有办法让十进制编辑文本在启动时不关注?如果有任何问题,我正在使用 API > 23。
正如在查看其他人对类似问题提供的答案时的旁注一样,我希望我的领域不会受到关注。我不想只隐藏软键盘而保持焦点。
将此添加到 manifest
activity
标签
android:windowSoftInputMode="stateHidden|adjustResize"
代码类似于清单
<activity
android:name=".ActivityName"
android:windowSoftInputMode="stateHidden|adjustResize" />
This will help hide soft keyboard at startup
并将这些标签添加到您的根布局而不是父布局
android:focusable="true"
android:focusableInTouchMode="true"