When you enter content in the edit box, the soft keyboard pops up, and the screen area of the mobile phone often obscures the input interface, so let's look at the problem:
When entering user name and password, the system will pop up the keyboard, causing the system keyboard to block the text box problem:
Enter the password when the input box is blocked by the system keyboard, greatly reducing the user experience, this is the development of a very common soft keyboard occlusion problem, how to solve?
Method One
Write this code before setcontentview in your activity's oncreate.
GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Method Two
In the project's Androidmanifest.xml file interface corresponding to the <activity> added
This will make the screen move up the whole. If you add a android:windowsoftinputmode= "Adjustpan", the keyboard will overwrite the screen.
About Android:windowsoftinputmode
Activity main window and soft keyboard interaction mode, can be used to avoid Input Panel occlusion problem, after Android1.5 a new feature.
This genus affects two things:
"One" when the focus is generated, the soft keyboard is hidden or displayed
"Two" reduces the active main window size to make room for the soft keyboard
It must be set to a value in the list below, or a "state ..." value plus a combination of "adjust ..." values. Set multiple values in either group-multiple "state ..." values, such as &mdash, have undefined results. Each value is separated by |
For example:
<activityandroid:windowsoftinputmode= "Statevisible|adjustresize" ... >
The value set in this (except "stateunspecified" and "adjustunspecified") overrides the value set in the topic
Method Three
Replace the top layout with ScrollView, or add a layer of ScrollView to the top layout. This will roll the soft keyboard and the input box together, and the soft keyboard will always be at the bottom.
1. Main interface Layout file
2. Custom Linearlayoutview
This component can be implemented to hide and display certain areas based on the pop/close of the soft keyboard, which is the most critical part of the problem solving, with two main points:
① overriding onsizechanged methods
This method is the view life cycle method, which is called when the view size changes, such as vertical screen switching, soft keyboard popup. Here when the soft keyboard pops up causing the view dimension to change, it calls the Onsizechanged method, in which the core idea of implementing code is based on the size change, when the larger (soft keyboard pops up), some areas are hidden to give the editing interface enough space to display, when the recovery (soft keyboard off), And then show the hidden area.
② provides an implementation method of invoking an interface using a callback mechanism in the Keybordstatelistener interface.
3. Main interface Mainactivit
Keyboard popup:
Keyboard off:
Http://jingyan.baidu.com/article/86f4a73e77195e37d6526998.html
Four solutions for Android soft keyboard occlusion