簡體   English   中英

協調器布局中的ActionBar不再自定義searchview焦點

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

因此,我在該論壇上看到了各種問題,並嘗試了多種解決方案,但到目前為止都沒有奏效。 另外,以前沒有一個使用協調器布局。 基本上,我在操作欄之外有一個自定義searchview,它在recylerview列表中進行搜索。 但是,將焦點放在SearchView上后,軟鍵盤將打開並隱藏整個ActionBar和recyclerview頂部的某些部分,即使在滾動之前,直到關閉鍵盤時,該部分都不會顯示。 xml代碼如下,可以根據要求發布任何其他代碼。

編輯:在清單中使用AdjustResize解決了隱藏的操作欄的問題,但是一旦放棄了鍵盤,則將空白留為屏幕大小的四分之一。 可能是因為它也在調整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>

在清單中,嘗試在活動中添加以下行:

android:windowSoftInputMode="adjustPan|adjustNothing"

這可能會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM