ログインインターフェイスはフルスクリーン+背景画像没入型+キーボードは入力ボックスをポップアップします+キーボードはポップアップします、背景はポップアップまたは圧縮されません

要求する:

  • インターフェイスのバックグラウンドイマージョン
  • キーボードのポップアップ入力ボックスはブロックされません
  • キーボードがポップアップし、背景が動かない

レンダリングは次のとおりです。
ここに画像の説明を挿入します

インターフェースレイアウトファイル:(以下のLinearLayoutのように、ジャッキアップする必要のあるレイアウトにandroid:fitsSystemWindows = "true"属性を追加します)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fl_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/bg" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:layout_marginBottom="20dp"
        android:fitsSystemWindows="true"
        android:orientation="vertical">

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:background="@null"
            android:hint="请输入账号"
            android:paddingLeft="8dp"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:textSize="18sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="@color/colorAccent" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginTop="12dp"
            android:background="@null"
            android:hint="请输入密码"
            android:paddingLeft="8dp"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:textSize="18sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:background="@color/colorAccent" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginTop="20dp"
            android:background="@android:color/white"
            android:text="登录"
            android:textSize="18sp" />
    </LinearLayout>

</RelativeLayout>

マニフェストファイルの構成:(android:windowSoftInputMode = "adjustResize | stateAlwaysHidden")

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.keyboard">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

インターフェイスアクティビティコード:

package com.example.keyboard;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.gyf.immersionbar.ImmersionBar;

public class MainActivity extends AppCompatActivity {
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //沉浸
        ImmersionBar.with(this).init();
    }
}

build.gradleの依存関係:(イマージョン用のイマージョンバーを追加)

    implementation 'com.gyf.immersionbar:immersionbar:3.0.0'

隠れた問題(使用には影響しません):
この問題を示すために、レイアウトのすべての余白を削除し、LinearLayoutとサブコントロールに異なる色を追加します。上の高さのギャップなどの追加のステータスバーがあることがわかります。 android:fitsSystemWindows属性を追加するLinearLayout。これを削除する方法はありませんが、レイアウトの上部に持ち上げる必要のある他のコントロールがないため、他のコントロールを追加する必要がある場合でも、使用に影響します。エディットテキストで、これらをこのLinearLayoutに追加できます。
ここに画像の説明を挿入します
他の解決策を試してください:
adjustResizeを解決し、全画面イマージョンモードが競合する場合、参照接続でAndroidBug5497回避モードを使用しましたが、キーボードがポップアップすると、キーボードの上のステータスバーの高さの空白の位置。泥を引き出すために大根を実際に引き出しているので、適切な解決策が見つかりませんでした。そのため、AndroidBug5497回避方法は廃止されました。

その他のアプリログインインターフェースの設計:

  • 1つのタイプは、ユーザーがログインして使用するホームページにのみ入ることができるというものです。この種のアプリは通常、複数のログイン方法をサポートしているため、ログインインターフェイスには入力ボックスはなく、さまざまな種類のログイン方法のジャンプボタンがあります。したがって、フルスクリーン+イマージョンは表示されません+キーボード+入力ボックスはブロックされません+背景は圧縮されませんなど。

例:リトルレッドブックここに画像の説明を挿入します

  • もう1つのタイプはアプリを入力することで、直接使用できます。ユーザーが情報を投稿する必要がある場合、または自分のログインインターフェースをアクティブにクリックしてログインインターフェースに入る場合にのみ、ログインインターフェースに入ります。この方法で入力されたログインインターフェースには通常背景画像、このインターフェースは設計されているため、ユーザーに情報を伝えるために背景画像を使用する必要はありません。
    例:Douyin
    ここに画像の説明を挿入します
    要約すると、現在の記事では、この設計のケースは多くありません。それ、あなたはそれを解決するために上記のステップに従うことができます;この記録だけ、あなたが質問をするならば、コメントを残してください、ありがとう

参照接続1.Android
入力方式ボックスのポップアップ背景シフトまたは圧縮の問題
2.全画面アクティビティの入力ボックスをブロックするキーボードの問題を解決する、全画面ブロックEdittext、全画面入力ボックスのバグ、AndroidBug5497
回避策、没入型入力ボックス3. Android Adjustresize全画面無効の問題
4.Androidがソフトキーボードのポップアップを認識し、editTextがキーボードとともに上に移動し、背景が移動しない

おすすめ

転載: blog.csdn.net/nongminkouhao/article/details/107983535