Android開發軟鍵盤遮擋登陸按鈕的完美解決方案
在應用程式登陸頁面我們需要填寫使用者名稱和密碼。當填寫這些資訊的時候,軟鍵盤會遮擋登陸按鈕,這使得使用者體驗較差,所以今天就來解決這個問題
1:登陸佈局介面如下
<?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>
需要注意的是:
1:層級關係
RelativeLayout-----
LinearLayout----
ScrollView,
Button
2:在AndroidManifest.xml中的該activity配置:window代碼
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) { }; };
以上所述是小編給大家介紹的Android開發軟鍵盤遮擋登陸按鈕的完美解決方案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對PHP中文網的支持!
更多Android開發軟體鍵盤遮擋登陸按鈕的完美解決方案相關文章請關注PHP中文網!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

公司安全軟件導致部分應用無法正常運行的排查與解決方法許多公司為了保障內部網絡安全,會部署安全軟件。 ...

在使用MyBatis-Plus或其他ORM框架進行數據庫操作時,經常需要根據實體類的屬性名構造查詢條件。如果每次都手動...

系統對接中的字段映射處理在進行系統對接時,常常會遇到一個棘手的問題:如何將A系統的接口字段有效地映�...

將姓名轉換為數字以實現排序的解決方案在許多應用場景中,用戶可能需要在群組中進行排序,尤其是在一個用...

在使用IntelliJIDEAUltimate版本啟動Spring...

Java對象與數組的轉換:深入探討強制類型轉換的風險與正確方法很多Java初學者會遇到將一個對象轉換成數組的�...

電商平台SKU和SPU表設計詳解本文將探討電商平台中SKU和SPU的數據庫設計問題,特別是如何處理用戶自定義銷售屬...

在使用TKMyBatis進行數據庫查詢時,如何優雅地獲取實體類變量名以構建查詢條件,是一個常見的難題。本文將針...
