Android 当软键盘可见时,RecyclerView隐藏工具栏和布局

Android 当软键盘可见时,RecyclerView隐藏工具栏和布局,android,toolbar,android-softkeyboard,android-recyclerview,Android,Toolbar,Android Softkeyboard,Android Recyclerview,我有一个问题就是这样,同样的情况和布局中的相同组件。 唯一的区别是工具栏,但显然我使用的是appcompat,其行为是相同的 注意,不仅工具栏被隐藏,回收视图的上部也被隐藏。就像当软键盘可见时,整个片段向上翻译一样 我在活动的main.xml中使用了如下工具栏: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/an

我有一个问题就是这样,同样的情况和布局中的相同组件。 唯一的区别是工具栏,但显然我使用的是appcompat,其行为是相同的

注意,不仅工具栏被隐藏,回收视图的上部也被隐藏。就像当软键盘可见时,整个片段向上翻译一样

我在活动的main.xml中使用了如下工具栏:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/container_root"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

框架布局替换为以下内容:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:ignore="MergeRootFrame" >

    <!--<include layout="@layout/toolbar" />-->

    <com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@color/primary"
        android:textColor="#FFFFFF"
        app:pstsIndicatorColor="#FFFFFF"
        app:pstsPaddingMiddle="true"
        android:maxHeight="20dp"
        android:elevation="5dp"
    />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    </LinearLayout>

在查看页面中,我有一个标签,上面有这个片段的布局和recyclerview:

<?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:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerViewChat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="50dip"/>


    <EditText
        android:id="@+id/txtChatLine"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/txt_hint"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:layout_toStartOf="@+id/button1">
    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btn_send"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>


当我开始在edittext中输入文本时,整个布局会上升,工具栏不可见(在屏幕外),recyclerview不会滚动,但会向上移动。

我刚刚遇到同样的问题,@drakeet解决方案对我有效:

我在工具栏和RecyclerView之间包含了一个空的滚动视图,工具栏停止隐藏

<include android:id="@+id/app_bar" layout="@layout/toolbar"/>

<!--Empty ScrollView needed so the recyclerview doesn't hide the toolbar-->
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</ScrollView>

<view
    android:id="@+id/recycler_view"
    android:layout_below="@id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="android.support.v7.widget.RecyclerView"
    android:layout_above="@+id/message_layout"/>


从AndroidManifest.xml中删除android:WindowsOfInputMode=“adjustPan”删除adjustPan等于设置adjustUnspecified,如果存在可滚动元素,则默认为adjustResize。如果这解决了您的问题,我认为您应该显式地编写
android:windowSoftInputMode=“adjustResize”
,让代码的读者了解您确实想要这个值。