RecyclerView隐藏动作条,当SoftKeyboard打开 [英] RecyclerView hides Actionbar when SoftKeyboard is opened
问题描述
我有以下布局
<?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>
虽然SendMessageLayout仅仅是一个的EditText和一个按钮的布局。 在旧的实现,我用普通的旧的ListView,所以当我要求重点用于编辑文本键盘会出现在列表视图未动,并且第一个项目是可见的。 但与RecyclerView一切被向上推,不仅最上面的项目是在屏幕的,但它的整个布局是在动作条的顶部上。
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...
推荐答案
只需添加一个空的滚动视图,解决了:<一href="http://drakeet.me/solve-a-stackoverflow-post-recyclerview-hides-actionbar-when-softkeyboard-is-opened">RecyclerView隐藏动作条,当SoftKeyboard打开解决办法
Just add a empty scrollview, solved: RecyclerView hides Actionbar when SoftKeyboard is opened 解决办法
这样的:
<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>
这篇关于RecyclerView隐藏动作条,当SoftKeyboard打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!