Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView hides Actionbar when SoftKeyboard is opened

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... RecycleView Screenshot

like image 639
alexk Avatar asked Nov 30 '14 11:11

alexk


1 Answers

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>
like image 113
drakeet Avatar answered Oct 18 '22 00:10

drakeet