在應用程式登陸頁面我們需要填寫使用者名稱和密碼。當填寫這些資訊的時候,軟鍵盤會遮擋登陸按鈕,這使得使用者體驗較差,所以今天就來解決這個問題
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中文網!

本文討論了使用咖啡因和Guava緩存在Java中實施多層緩存以提高應用程序性能。它涵蓋設置,集成和績效優勢,以及配置和驅逐政策管理最佳PRA

本文使用lambda表達式,流API,方法參考和可選探索將功能編程集成到Java中。 它突出顯示了通過簡潔性和不變性改善代碼可讀性和可維護性等好處

Java的類上載涉及使用帶有引導,擴展程序和應用程序類負載器的分層系統加載,鏈接和初始化類。父代授權模型確保首先加載核心類別,從而影響自定義類LOA

本文討論了使用JPA進行對象相關映射,並具有高級功能,例如緩存和懶惰加載。它涵蓋了設置,實體映射和優化性能的最佳實踐,同時突出潛在的陷阱。[159個字符]

本文討論了使用Maven和Gradle進行Java項目管理,構建自動化和依賴性解決方案,以比較其方法和優化策略。

本文使用選擇器和頻道使用單個線程有效地處理多個連接的Java的NIO API,用於非阻滯I/O。 它詳細介紹了過程,好處(可伸縮性,性能)和潛在的陷阱(複雜性,

本文使用Maven和Gradle之類的工具討論了具有適當的版本控制和依賴關係管理的自定義Java庫(JAR文件)的創建和使用。

本文詳細介紹了用於網絡通信的Java的套接字API,涵蓋了客戶服務器設置,數據處理和關鍵考慮因素,例如資源管理,錯誤處理和安全性。 它還探索了性能優化技術,我


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

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

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

Dreamweaver CS6
視覺化網頁開發工具

WebStorm Mac版
好用的JavaScript開發工具