如何使EditText上创建活动时,不集中 [英] How to make EditText not focused when creating Activity
问题描述
在你downvote,并标记为重复,看我的问题。
Before you downvote and mark as duplicate, read my question.
我读过的其他问题讨论这一点,所有的人都为我的布局,除了作为创建的第一个之一。
I've read the other questions discussing this, and all of them work for my layouts, except for the very first one created.
目前,这是我的的onCreate
方法的顶部:
At the moment, this is at the top of my onCreate
method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
^,使得它如此至少的键盘不弹出启动时,但的EditText
仍然集中在。
这是 XML
我的的EditText
:
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/changePass"
android:layout_centerHorizontal="true"
android:layout_marginTop="167dp"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
android:maxLength="30" >
</EditText>
这是个什么样子,当我把我的活动,如:
This is what it looks like when I bring up my activity:
问题是,一些手机,当的EditText
的重点是这样的,他们不能把它写。我想它的不可以焦点。
The problem is that with some phones, when an EditText
is focused like this, they can't write in it. I want it to not focus.
我已经为它的 EditTexts
不集中,同时将寻求更多同类产品提出了下一个布局完成的作品:
What I've done works for the next layouts brought up in that it the EditTexts
are not focused on and would look more like this:
请注意,这是相同的布局,虽然。这是在用户已被带回这个屏幕,这将表明没有错 XML屏幕
,因为这是同一个 XML
,但问题是,的EditText
只集中在创建活动时启动。
Notice that it's the same layout, though. This is the screen after the user has been brought back to this screen, which would indicate nothing wrong with the XML
because this is the same XML
, but the problem is that the EditText
is only focused on when the activity is created.
我已经做了研究和所有的其他问题不帮我解决这个(他们可是帮了键盘显示不出来,谢天谢地)。我怎样才能使它所以的EditText
在启动时会像第二个屏幕,而不是第一?
I've done research and all of the other questions don't help me with this (they did however help the keyboard not show up, thankfully). How can I make it so the EditText
on startup will look like the second screenshot, rather than the first?
推荐答案
您可以设置布局的属性如安卓descendantFocusability =beforeDescendants
和 Android的:focusableInTouchMode =真正的
You can set property of Layout like android:descendantFocusability="beforeDescendants"
and android:focusableInTouchMode="true"
示例:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" >
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/changePass"
android:layout_centerHorizontal="true"
android:layout_marginTop="167dp"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
android:maxLength="30" >
</EditText>
</RelativeLayout>
五月这一个有益的;)
May this one helpful ;)
这篇关于如何使EditText上创建活动时,不集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!