In the application landing page we need to fill in the username and password. When filling in this information, the soft keyboard will block the landing button, which makes the user experience is poor, so today to solve this problem
1: The landing layout interface is as follows
<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http://schemas.android.com/apk/res/" Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" @drawable LOGIN_BG "> <linearlayout android:id=" @+id/ll_center "android:layout_width=" Fill_parent "Android:layout_" height= "wrap_content" android:orientation= "vertical" > <scrollview android:id= "@+id/sl_center" android:layout _width= "Fill_parent" android:layout_height= "0DP" android:layout_weight= "1" android:fadingedge= "None" Android: scrollbars= "None" > <relativelayout android:id= "@+id/rl_center" android:layout_width= "Fill_parent" Android: layout_height= "Wrap_content" > <linearlayout android:id= "@+id/sms_login_ll_title" android:layout_width= "wrap" _content "android:layout_height=" Wrap_content "android:layout_centerhorizontal=" true "android:layout_margintop=" 90dip "android:orientation=" horizontal "> <imageview android:id="@+id/sms_login_iv_icon "android:layout_width=" 70dip "android:layout_height=" 70dip "android:layout_gravity=" center
_vertical "android:src=" @drawable/login_top_icon "/> <imageview android:id=" @+id/sms_login_iv_big_text " Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_gravity= "center_vertical" "Android:layout_marginleft=" 15dip "android:src=" @drawable/sms_login_icon_big "/> </LinearLayout> < ImageView android:id= "@+id/sms_login_iv_name" android:layout_width= wrap_content "android:layout_height=" Wrap_ Content "android:layout_below=" @id/sms_login_ll_title "android:layout_centerhorizontal= true" Android:layout_ margintop= "28dip" android:background= "@drawable/sms_login_icon_small"/> <relativelayout android:id= "@+id/ Sms_login_rl_input_name "android:layout_width=" fill_parent "android:layout_height=" 43dip "android:layout_below=" @ Id/sms_login_iv_name "android:layout_centerhorizontal=" true "android:layout_marginleft= "40dip" android:layout_marginright= "40dip" android:layout_margintop= "40dip" android:background= "@drawable Login_top_input "> <imageview android:id=" @+id/sms_login_iv_input_name_icon "android:layout_width=" Wrap_ Content "android:layout_height=" Wrap_content "android:layout_alignparentleft=" true "android:layout_centervertical = "true" android:layout_marginleft= "10dip" android:layout_marginright= "10dip" android:background= "@drawable/login_
Input_icon_user "/> <framelayout android:layout_width= fill_parent" android:layout_height= "Wrap_content" Android:layout_centervertical= "true" android:layout_torightof= "@id/sms_login_iv_input_name_icon" > < EditText android:id= "@+id/sms_login_et_accout" android:layout_width= fill_parent "android:layout_height=" Wrap_ Content "android:background=" @drawable/transparent_white "android:digits=" @string/sms_login_accout_text "Android: Hint= "Please enter account" android:singleline= "true" android:text= "" android:textsize= "20sp"/> </framelayout> </RelativeLayout> <relativelayout android:id= "@+id/sms_login_rl_input_pass" Android:
Layout_width= "Fill_parent" android:layout_height= "43dip" android:layout_below= "@id/sms_login_rl_input_name"
Android:layout_centerhorizontal= "true" android:layout_marginleft= "40dip" android:layout_marginright= "40dip"
android:background= "@drawable/login_top_input" > <imageview android:id= "@+id/sms_login_iv_input_pass_icon"
Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentleft= "true" Android:layout_centervertical= "true" android:layout_marginleft= "10dip" android:layout_marginright= "10dip" Android : background= "@drawable/login_input_icon_pwd"/> <framelayout android:layout_width= "Fill_parent" Android: layout_height= "Wrap_content" android:layout_centervertical= "true" android:layout_torightof= "@id/sms_login_iv_ Input_pass_icon "> <edittext android:id=" @+id/sms_login_et_password "android:layouT_width= "Fill_parent" android:layout_height= "wrap_content" android:background= "@drawable/transparent_white"
android:digits= "@string/sms_et_change_password_old_text" android:hint= "Please enter password" android:inputtype= "TextPassword" Android:singleline= "true" android:text= "" android:textsize= "20sp"/> </FrameLayout> </relativelayout > </RelativeLayout> </ScrollView> <button android:id= "@+id/sms_login_bt_confirm" Android:layout_
Width= "Fill_parent" android:layout_height= "wrap_content" android:layout_below= "@id/sms_login_rl_input_pass"
Android:layout_centerhorizontal= "true" android:layout_marginleft= "40dip" android:layout_marginright= "40dip"
android:layout_margintop= "16dip" android:background= "@drawable/sms_update_pass_bg_selector" android:text= "Login" Android:textcolor= "@color/white" android:textsize= "20sp"/> </LinearLayout> </RelativeLayout>
It is to be noted that:
1: Hierarchical relationship
Relativelayout-----
LinearLayout----
ScrollView,
Button
2: The activity in Androidmanifest.xml is configured android:windowsoftinputmode= "Statehidden|adjustresize"
3: Look at the following code
Etaccount = (edittext) This.findviewbyid (r.id.sms_login_et_accout);
Etaccount.setonclicklistener (this);
Etaccount.setontouchlistener (New Ontouchlistener () {
@Override public
boolean Ontouch (View V, motionevent Event) {
changescrollview ();
return false;
}
});
/**
* makes ScrollView point to bottom/
private void Changescrollview () {
h.postdelayed (new Runnable () {
@ Override public
Void Run () {
sl_center.scrollto (0, Sl_center.getheight ());
}
Handler h = new Handler () {public
void Handlemessage (msg) {
};
The above is a small series to introduce the Android development soft keyboard occlusion landing button Perfect solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!