带导航栏的键盘向上移动framelayout

问题描述 投票:0回答:1

只有在使用全屏模式(三星galaxy s8)时才会出现问题,当键盘打开时,帧布局被迫向上移动。

        <activity ...
        android:windowSoftInputMode="adjustPan">

在这个活动中我们使用这样的层次结构:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:gravity="center"
android:orientation="vertical">

<FrameLayout
    android:id="@+id/actHomeBottomContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:background="@color/white"
    android:foregroundGravity="top" />

<FrameLayout
    android:id="@+id/actHomeTopContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    android:elevation="@dimen/grid_size"
    android:focusable="true"
    android:focusableInTouchMode="true" />

<ImageView
    android:id="@+id/actHomeLogo"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/grid_size_8x"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_margin="@dimen/grid_size_2x"
    android:elevation="@dimen/grid_size"
    android:src="@drawable/img_tbc_logo"
    android:visibility="gone" />

图像视图保持相同的位置,但

actHomeTopContainer

键盘隐藏/显示动作开始上下移动。键盘显示自

“actHomeBottomContainer”

在此之前我们做动画 - 翻译Y.

   actHomeTopContainer.animate().translationY(-1 * translateYSize).start()

其实我不知道三星如何选择观点向上移动。

android android-layout fullscreen android-softkeyboard samsung-galaxy
1个回答
0
投票

而不是使用adjustPan

<activity ...
    android:windowSoftInputMode="adjustPan">

你可以使用adjustNothing

<activity ...
    android:windowSoftInputMode="adjustNothing">

因为当您使用adjustPan时,窗口的内容会自动平移,以便键盘不会遮挡当前焦点,用户始终可以看到他们正在键入的内容。

© www.soinside.com 2019 - 2024. All rights reserved.