【问题标题】:Stop Decimal EditText from gaining focus on startup阻止 Decimal EditText 获得对启动的关注
【发布时间】:2018-09-11 12:36:26
【问题描述】:

我有followed this solution 防止编辑文本专注于活动启动。并这样实现它

<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。

就像查看其他人提供的类似问题的答案的旁注一样,我希望我的领域不要集中注意力。我不想只隐藏软键盘而是保持焦点。

【问题讨论】:

  • 你试过android:windowSoftInputMode="stateHidden"
  • 你的代码对我来说很好

标签: android android-layout android-edittext focus


【解决方案1】:

将此添加到manifest 中的activity 标记

android:windowSoftInputMode="stateHidden|adjustResize"

代码在清单中的样子

 <activity
            android:name=".ActivityName"
            android:windowSoftInputMode="stateHidden|adjustResize" />

这将有助于在启动时隐藏软键盘

并将这些标签添加到您的根布局而不是父布局

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

【讨论】:

  • 为我解决的问题是将 android:focusable="true" android:focusableInTouchMode="true" 添加到根布局而不是父布局。谢谢!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-16
  • 2011-01-09
  • 1970-01-01
  • 1970-01-01
  • 2013-08-23
  • 1970-01-01
相关资源
最近更新 更多