prevent背景调整大小和prevent自动对焦上的活动启动 [英] Prevent background resize AND prevent auto-focus on activity start
问题描述
查找上堆栈溢出的各种问题后,我发现许多人存在以下问题:
- 背景被软键盘打开时调整
- 软键盘活动开始时打开
在解决这两个谎言的 ActivityManifest.xml
。
要prevent从软键盘打开时被调整的背景图片,你可以添加的android:windowSoftInputMode =stateVisible | adjustPan
到<活动方式>
在清单
要prevent软键盘开幕活动开始时,你可以添加的android:windowSoftInputMode =stateHidden
到<活动方式>
在清单
这是一个解决方案,需要 stateHidden
和其他需要的事实 stateVisible
意味着我不能使用这两种解决方案。我从偷焦点上的活动的开始,但希望prevent软键盘的也 prevent软键盘从调整的背景,当用户的确实的决定专注于的EditText
。
有没有一个可行的解决方案,这两个问题?
事实上,一个解决方案需要stateHidden和其它需要
stateVisible意味着我不能使用这两种解决方案。
块引用>是的。但是,你可以使用
stateHidden |。adjustPan
除非用户点击
的EditText
键盘不会弹出。和你的背景的潜在变化将在定位方面;不会发生的背景缩放After looking up various questions on stack overflow, I have found that many other people had the following problems:
- Background gets resized when soft keyboard opens
- Soft keyboard opens when activity starts
The solution to both of these lies in the
ActivityManifest.xml
.To prevent the background image from being resized when the soft keyboard opens, you can add
android:windowSoftInputMode="stateVisible|adjustPan"
to the<activity>
in the manifest.To prevent the soft keyboard opening when the activity starts, you can add
android:windowSoftInputMode="stateHidden"
to the<activity>
in the manifest.The fact that one solution requires
stateHidden
and the other requiresstateVisible
means that I cannot use both solutions. I am looking to prevent the soft keyboard from stealing focus on activity start but also prevent the soft keyboard from resizing the background when the user does decide to focus on theEditText
.Is there a viable solution to both of these issues?
解决方案The fact that one solution requires stateHidden and the other requires stateVisible means that I cannot use both solutions.
Yes. But, you can use
stateHidden|adjustPan
.Keyboard will not pop up unless user clicks on an
EditText
. And potential changes to your background will be in terms of positioning; scaling of the background will not occur.这篇关于prevent背景调整大小和prevent自动对焦上的活动启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!