RecyclerView hides Actionbar when SoftKeyboard is opened

佐手、 提交于 2019-12-06 00:00:23

问题


I have the following Layout

<?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:id="@+id/container">

    <com.example.SendMessageLayout
        android:id="@+id/chatMessageLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        />

    <View
        android:id="@+id/separator"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_above="@id/chatMessageLayout"
        android:background="@color/seperator_line_inpost"
        />

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_above="@id/separator"
        >

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycleView"
            style="@style/BeepMeListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/chatMessageLayout"
            android:layout_alignParentTop="true"
            android:transcriptMode="alwaysScroll"
            />
    </android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

While SendMessageLayout is just a layout with EditText and a Button. In the old implementation i used plain old ListView, so when i requested focus for the edit text a keyboard would appear, the listview didn't move, and the first item was visible. But with the RecyclerView everything is pushed up, not only the top item is out of the screen but it the whole layout is on top of the ActionBar.

Here's how it looks...


回答1:


Just add a empty scrollview, solved: RecyclerView hides Actionbar when SoftKeyboard is opened 解决办法

Like this:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    tools:context="me.drakeet.seashell.ui.social.PostActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ScrollView>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <me.drakeet.seashell.widget.MultiSwipeRefreshLayout
            android:layout_weight="1"
            android:layout_marginBottom="4dp"
            android:id="@+id/swipe_refresh_layout"
            style="@style/BbsBackground"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_reply_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:minHeight="48dp"/>

        </me.drakeet.seashell.widget.MultiSwipeRefreshLayout>

        <include
            android:layout_gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            layout="@layout/view_reply"/>
    </LinearLayout>

</FrameLayout>



回答2:


i had the same issue and i solved it adding

android:windowSoftInputMode="adjustResize"

in the activity tag in the manifest



来源:https://stackoverflow.com/questions/27212580/recyclerview-hides-actionbar-when-softkeyboard-is-opened

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!