当SoftKeyboard可见时,RecyclerView隐藏工具栏和布局 [英] RecyclerView hides Toolbar and layout when SoftKeyboard is visible
问题描述
我遇到的问题完全与此 LINK 相同,情况和布局中的相同组件. 唯一的区别是工具栏,但显然我使用的是appcompat,其行为是相同的.
I've a problem exactly like this LINK, same situation and same components in layouts. The only difference is the toolbar, but obviously i'm using appcompat and the behaviour is the same.
注意,不仅隐藏了工具栏,而且还隐藏了recyclerview的上部.就像在可见软键盘时将整个片段向上翻译一样.
Attention, not only the toolbar is hided, but also the upper part of the recyclerview. Is like if the entire fragment is translated up when the softkeyboard is visible.
我在活动的main.xml中使用了这样的工具栏:
I'm using a toolbar like this in the main.xml of my activity:
<?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片段布局的选项卡:
And inside the view pager i've a tab with this fragment's layout with the 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不会滚动,但会向上移动.
When i start to enter text in the edittext the entire layout goes up, the toolbar become invisible (out of the screen) and the recyclerview doesn't scroll, but it's move up.
推荐答案
我只是遇到了同样的问题,@ drakeet解决方案为我工作: 打开SoftKeyboard时,RecyclerView隐藏操作栏
I just had the same problem and @drakeet solution worked for me: RecyclerView hides Actionbar when SoftKeyboard is opened
我在工具栏和RecyclerView之间插入了一个空的ScrollView,并且工具栏停止了隐藏.
I included an empty ScrollView between the Toolbar and the RecyclerView and the Toolbar stopped hiding.
<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"/>
这篇关于当SoftKeyboard可见时,RecyclerView隐藏工具栏和布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!