带有导航栏的键盘将框架布局向上移动

时间:2019-02-27 12:10:58

标签: android android-layout fullscreen android-softkeyboard samsung-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()

实际上,我不知道三星是如何选择要向上移动的视图的。

1 个答案:

答案 0 :(得分:0)

代替使用adjustPan

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

您可以使用adjustNothing

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

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