簡體   English   中英

打開鍵盤后,Android會向上移動頁腳

[英]Android move footer up when keyboard is open

我正在設計一個登錄HTML頁面,該頁面已加載到Android WebView中。 頁面底部固定有兩個文本區域和一個“登錄”按鈕。 我的問題是,當該人鍵入文本區域時; 鍵盤彈出並隱藏登錄按鈕。

如何將“登錄”按鈕固定在頁面底部但固定在鍵盤頂部?

我試過了 :

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

android:windowSoftInputMode="adjustPan|adjustResize"

兩者都沒有影響。

您需要做的是將按鈕放在RelativeLayout ,然后為其指定以下屬性:

android:layout_alignParentBottom="true"

當為鍵盤調整屏幕大小時,由於RelativeLayout針對剩余的屏幕空間進行調整,因此按鈕會隨鍵盤向上推。

這是一個帶有一個按鈕的完整工作代碼示例:

<!--Parent view-->
<RelativeLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!--Login Button-->
    <Button
        android:id="@+id/btnLogin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

編輯

要將元素固定到網頁頁面的底部,您需要對html / css進行以下修改。

.login-button {
    position: fixed;
    bottom: 0;
    width: 100%;
}

按鈕文字

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM