Home Java javaTutorial The perfect solution for Android development soft keyboard to block the login button

The perfect solution for Android development soft keyboard to block the login button

Jan 07, 2017 am 11:39 AM

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>
Copy after login

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) { 
}; 
};
Copy after login

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!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

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. ...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

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...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

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...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

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

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

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...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

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...

How to elegantly get entity class variable name building query conditions when using TKMyBatis for database query? How to elegantly get entity class variable name building query conditions when using TKMyBatis for database query? Apr 19, 2025 pm 09:51 PM

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...

See all articles