Mimic login interface soft keyboard pops up without overwriting the effect of the landing button below

Source: Internet
Author: User

Activity_main.xml

<?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= "#E6E6E6"android:orientation= "Vertical" > <Com.eiice.xiaokeke.SoftKeyBoardSatusView Android:id= "@+id/login_soft_status_view"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" > </com.example.test.SoftKeyBoardSatusView> <LinearLayout Android:id= "@+id/login_layout"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"android:orientation= "Vertical" > <ImageView Android:id= "@+id/login_icon"Android:layout_width= "75DP"Android:layout_height= "75DP"android:layout_gravity= "Center_horizontal"Android:layout_margintop= "100DP"android:src= "@drawable/default_head_icon"/> <LinearLayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:layout_marginleft= "20DP"Android:layout_marginright= "20DP"Android:layout_margintop= "5DP"Android:background= "@drawable/login_edit_bg"android:orientation= "Vertical"Android:paddingtop= "10DP" > <relativelayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content" > <EditText Android:id= "@+id/login_edit_account"Android:layout_width= "Fill_parent"Android:layout_height= "45DP"Android:layout_marginright= "65DP"Android:background= "@android: Color/transparent"android:gravity= "Center_vertical"Android:hint= "Please enter account"Android:paddingleft= "10DP"Android:singleline= "true"Android:textcolor= "@android: Color/black"android:textsize= "18sp"/> <ImageView Android:id= "@+id/login_arrow"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentright= "true"android:layout_centervertical= "true"Android:paddingbottom= "10DP"Android:paddingleft= "5DP"Android:paddingright= "7DP"Android:paddingtop= "10DP"android:src= "@drawable/arro_down"android:textsize= "18sp"/> <ImageView Android:id= "@+id/login_account_edit_clear"Android:layout_width= "16DP"Android:layout_height= "16DP"android:layout_centervertical= "true"Android:layout_marginright= "2DP"Android:layout_toleftof= "@id/login_arrow"android:src= "@drawable/common_input_box_clear"/> </RelativeLayout> <View android:layout_width= "Fill_parent"Android:layout_height= "1px"Android:background= "@android: Color/darker_gray"/> <relativelayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"android:orientation= "Horizontal" > <EditText Android:id= "@+id/login_edit_password"Android:layout_width= "Fill_parent"Android:layout_height= "45DP"Android:layout_marginright= "65DP"Android:background= "@android: Color/transparent"android:gravity= "Center_vertical"Android:hint= "Please enter password"Android:inputtype= "Textpassword"Android:paddingleft= "10DP"Android:paddingright= "45DP"Android:singleline= "true"Android:textcolor= "@android: Color/black"android:textsize= "18sp"/> <ImageView Android:id= "@+id/login_password_edit_clear"Android:layout_width= "16DP"Android:layout_height= "16DP"Android:layout_alignparentright= "true"android:layout_centervertical= "true"Android:layout_marginright= "5DP"android:src= "@drawable/common_input_box_clear"/> </RelativeLayout> </LinearLayout> <Button Android:id= "@+id/login_login_btn"Android:layout_width= "Fill_parent"Android:layout_height= "45DP"Android:layout_marginleft= "20DP"Android:layout_marginright= "20DP"Android:layout_margintop= "40DP"Android:background= "@drawable/login_btn_selector"android:gravity= "Center"Android:text= "Login"Android:textcolor= "@android: Color/white"android:textsize= "22SP"Android:textstyle= "Bold"/> <Button Android:id= "@+id/login_register_btn"Android:layout_width= "Fill_parent"Android:layout_height= "45DP"Android:layout_marginbottom= "20DP"Android:layout_marginleft= "20DP"Android:layout_marginright= "20DP"Android:layout_margintop= "20DP"Android:background= "@drawable/login_btn_selector"android:gravity= "Center"Android:text= "Register"Android:textcolor= "@android: Color/white"android:textsize= "22SP"Android:textstyle= "Bold"/> </LinearLayout></RelativeLayout>

Mainactivity.java

 PackageCom.eiice.xiaokeke;ImportCOM.EXAMPLE.TEST.R;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.Button;Importandroid.widget.LinearLayout; Public classMainactivityextendsActivityImplementsSoftkeyboardsatusview.softkeyboardlistener {Button button_register;    Softkeyboardsatusview Satusview;    LinearLayout login_layout; intSCROLL_DX; intScreenHeight; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Button_register=(Button) Findviewbyid (R.ID.LOGIN_REGISTER_BTN); Satusview=(Softkeyboardsatusview) Findviewbyid (R.id.login_soft_status_view); Login_layout=(LinearLayout) Findviewbyid (r.id.login_layout); ScreenHeight=Getwindowmanager (). Getdefaultdisplay (). GetHeight (); Satusview.setsoftkeyboardlistener ( This); } @Override Public voidKeyboardstatus (intWintHintOLDW,intOLDH) {} @Override Public voidKeyboardvisable (intmove) {        int[] location =New int[2];        Button_register.getlocationonscreen (location); intBtntobottom = screenheight-location[1]-button_register.getheight (); SCROLL_DX= btntobottom > Move? 0:move-Btntobottom; Login_layout.scrollby (0, SCROLL_DX); } @Override Public voidKeyboardinvisable (intmove) {Login_layout.scrollby (0,-SCROLL_DX); }}

Softkeyboardsatusview.java

 PackageCom.eiice.xiaokeke;ImportCOM.EXAMPLE.TEST.R;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.Button;Importandroid.widget.LinearLayout; Public classMainactivityextendsActivityImplementsSoftkeyboardsatusview.softkeyboardlistener {Button button_register;    Softkeyboardsatusview Satusview;    LinearLayout login_layout; intSCROLL_DX; intScreenHeight; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Button_register=(Button) Findviewbyid (R.ID.LOGIN_REGISTER_BTN); Satusview=(Softkeyboardsatusview) Findviewbyid (R.id.login_soft_status_view); Login_layout=(LinearLayout) Findviewbyid (r.id.login_layout); ScreenHeight=Getwindowmanager (). Getdefaultdisplay (). GetHeight (); Satusview.setsoftkeyboardlistener ( This); } @Override Public voidKeyboardstatus (intWintHintOLDW,intOLDH) {} @Override Public voidKeyboardvisable (intmove) {        int[] location =New int[2];        Button_register.getlocationonscreen (location); intBtntobottom = screenheight-location[1]-button_register.getheight (); SCROLL_DX= btntobottom > Move? 0:move-Btntobottom; Login_layout.scrollby (0, SCROLL_DX); } @Override Public voidKeyboardinvisable (intmove) {Login_layout.scrollby (0,-SCROLL_DX); }}

Original address: http://download.csdn.net/download/lgl1170860350/8468565

Mimic login interface soft keyboard pops up without overwriting the effect of the landing button below

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.