简体   繁体   English

协调器布局中的ActionBar不再自定义searchview焦点

[英]ActionBar within Coordinator Layout goes away on custom searchview focus

So, I have seen various questions on this forum and have tried a number of solutions but none have worked so far. 因此,我在该论坛上看到了各种问题,并尝试了多种解决方案,但到目前为止都没有奏效。 Also, none of the previous have used Coordinator Layout. 另外,以前没有一个使用协调器布局。 Basically I have a custom searchview outside of the actionbar which searches within a recylerview list. 基本上,我在操作栏之外有一个自定义searchview,它在recylerview列表中进行搜索。 However, upon SearchView focus, the softkeyboard opens and hides the entire ActionBar and some part of the top of recyclerview, which does not show up even on scrolling until the keyboard is not closed. 但是,将焦点放在SearchView上后,软键盘将打开并隐藏整个ActionBar和recyclerview顶部的某些部分,即使在滚动之前,直到关闭键盘时,该部分都不会显示。 The xml code is as below, any further code can be posted on request. xml代码如下,可以根据要求发布任何其他代码。

EDIT: using adjustResize in manifest solves the problem of hidden Actionbar but leaves a whitespace one fourth the size of the screen once the keyboard is discarded. 编辑:在清单中使用AdjustResize解决了隐藏的操作栏的问题,但是一旦放弃了键盘,则将空白留为屏幕大小的四分之一。 Possibly because it is resizing the Recyclerview as well? 可能是因为它也在调整Recyclerview的大小?

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_scrollFlags="scroll|enterAlways" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:paddingLeft="6dp"
        app:tabMode="scrollable"/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_done" />

<SearchView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:background="@color/gray2Background"
    android:iconifiedByDefault="false"
    android:layout_marginLeft="36dp"
    android:layout_marginBottom="20dp"
    android:layout_marginRight="36dp"></SearchView>

In manifest try to add this line in the activity: 在清单中,尝试在活动中添加以下行:

android:windowSoftInputMode="adjustPan|adjustNothing"

It may be helpful. 这可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM