


The perfect solution for Android development soft keyboard to block the login button
On the application login page we need to fill in the username and password. When filling in this information, the soft keyboard will block the login button, which makes the user experience poor, so we will solve this problem today
1: The login 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="请输入账号" 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="请输入密码" 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="登 录" android:textColor="@color/white" android:textSize="20sp" /> </LinearLayout> </RelativeLayout>
Things to note Yes:
1: Hierarchical relationship
RelativeLayout-----
LinearLayout----
ScrollView,
Button
2: Configure the activity in AndroidManifest.xml 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; } }); /** * 使ScrollView指向底部 */ private void changeScrollView(){ h.postDelayed(new Runnable() { @Override public void run() { sl_center.scrollTo(0, sl_center.getHeight()); } }, 300); } Handler h = new Handler(){ public void handleMessage(Message msg) { }; };
The above is the editor I would like to introduce to you the perfect solution for Android development soft keyboard to block the login button. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more related articles on the perfect solution for Android development soft keyboard to block the login button, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Start Spring using IntelliJIDEAUltimate version...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

When using TKMyBatis for database queries, how to gracefully get entity class variable names to build query conditions is a common problem. This article will pin...
