Activityインタフェースにおけるedittext自動フォーカス取得(ソフトキーボードポップアップ)解決
5133 ワード
最近開発をしているときに困った問題があったのは、私のあるactivityページにeditTextがあり、入るとソフトキーボードが呼び出され、見た目が悪くなったのでapiを見てみました
http://developer.android.com/guide/topics/manifest/activity-element.html(要×××)
ノードの下、すなわちmanifestファイルのactivityノードを構成する際に構成する必要があります How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:The setting must be one of the values listed in the following table, or a combination of one "
Value
Description
"
The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will choose an appropriate state or rely on the setting in the theme.This is the default setting for the behavior of the soft keyboard.
"
The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.
"
The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"
The soft keyboard is always hidden when the activity's main window has input focus.
"
The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).
"
The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"
It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.This is the default setting for the behavior of the main window.
"
The activity's main window is always resized to make room for the soft keyboard on screen.
"
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
This attribute was introduced in API Level 3.つまり、この構成は主に2つのことをしています1、activityがフォーカスを取得したときにソフトキーボードが見えるかどうかを設定してください.2、(ソフトキーボードが小さくなったときにスペースを残したり、activityがソフトキーボードレイアウトを含んでいるときにこのactivityがフォーカスを取得したりしたとき【panはここでパネルを翻訳し、java GUIを学んだことがある人はみなpanleがあることを知っている】)activityの大きさに適応するように調整します.また、これは独立した属性がたくさんあります.設定したい属性がない場合は、以上の属性を組み合わせてみてください.組み合わせたときに「|」で分けるだけでいいです. が問題になりました.現在のactivityにedittextがあるという効果がありますが、デフォルトではポップアップされません.フォーカスを取得したときにのみソフトキーボードがポップアップされます.属性によって を見ることができます.
adjustUnspecified|stateHiddenという組み合わせは、私たちが望む効果を達成できるはずです.そこでactivityのノードに次のように構成します.
http://developer.android.com/guide/topics/manifest/activity-element.html(要×××)
ノードの下、すなわちmanifestファイルのactivityノードを構成する際に構成する必要があります
android:windowSoftInputMode
という属性は、ソフトキーボードのモードを制御する.api関連ソフトキーボードのクリップを以下に抜粋しました.android:windowSoftInputMode
state...
"value plus one "adjust...
"value. Setting multiple values in either group — multiple "state...
"values, for example — has undefined results. Individual values are separated by a vertical bar ( |
). For example:
Values set here (other than "stateUnspecified
"and "adjustUnspecified
") override values set in the theme. Value
Description
"
stateUnspecified
"The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will choose an appropriate state or rely on the setting in the theme.This is the default setting for the behavior of the soft keyboard.
"
stateUnchanged
"The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.
"
stateHidden
"The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"
stateAlwaysHidden
"The soft keyboard is always hidden when the activity's main window has input focus.
"
stateVisible
"The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).
"
stateAlwaysVisible
"The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
"
adjustUnspecified
"It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.This is the default setting for the behavior of the main window.
"
adjustResize
"The activity's main window is always resized to make room for the soft keyboard on screen.
"
adjustPan
"The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
This attribute was introduced in API Level 3.つまり、この構成は主に2つのことをしています1、activityがフォーカスを取得したときにソフトキーボードが見えるかどうかを設定してください.2、(ソフトキーボードが小さくなったときにスペースを残したり、activityがソフトキーボードレイアウトを含んでいるときにこのactivityがフォーカスを取得したりしたとき【panはここでパネルを翻訳し、java GUIを学んだことがある人はみなpanleがあることを知っている】)activityの大きさに適応するように調整します.また、これは独立した属性がたくさんあります.設定したい属性がない場合は、以上の属性を組み合わせてみてください.組み合わせたときに「|」で分けるだけでいいです.
adjustUnspecified|stateHiddenという組み合わせは、私たちが望む効果を達成できるはずです.そこでactivityのノードに次のように構成します.
api 。
,
/**
*
*
**/