开发者

Override EditText hint when ime is in fullscreen?

Can I override the hint and display a different hint when the app is in landscape mode and the EditText is in fullscreen?

For example, I have a TextView (label, say "User Name") and an EditText (to enter the user name, with hint "Mandatory"). However, when the app is in landscape mode and the EditText is in fullscreen, it would be a better user experience to provide a better hint - like "User Name is Mandatory" so that the user knows what the EditText is for.

Is there a method in EditText that checks if the ime i开发者_运维百科s in fullscreen?

[I tried looking at various apps like Twitter - they either do not override the hint or just have a hint that repeats their TextView/label. I do not want to do either of these]

Thanks.


I've never seen anything specifically for the "fullscreen mode" that EditText's get on devices with no hardware keyboard. But in general I would think that you could check for focus and change the hint accordingly. The downside is that the hint is going to change if the user uses scroll wheel to highlight the EditText


I would look at the display size and determine myself if I am in Landscape or Portrait.

Display defaultDisplay = getWindowManager().getDefaultDisplay(); 
int w = defaultDisplay.getWidth();
int h = defaultDisplay.getHeight();

if(w > h) {
    //landscape
} else {
    //portrait
}

There is a method getRotation() on the Display object, but that is the rotation value from its natural orientation, which, depending on device, may be Landscape or Portrait.

Otherwise I am not sure what you mean by fullscreen mode of an EditText.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜