0

我的应用中有这样的 Appbarlayout:

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:background="#33000000"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolBar"
            app:titleTextColor="@color/light_blue"
            android:title="@{viewModel.title}"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="enterAlways" />
        <SearchView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/searchView"
            android:queryBackground="@android:color/transparent"
            android:searchHintIcon="@drawable/ic_search"
            app:searchIcon="@drawable/ic_search"
            android:iconifiedByDefault="false"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            app:defaultQueryHint="Search"
            android:queryHint="Search" />
    </android.support.design.widget.AppBarLayout>

这在 API23 设备上运行良好,但在 API24 设备上,“wrap_content”隐藏了搜索视图,只显示工具栏......

如果我这样做:

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:background="#33000000"
        android:layout_width="match_parent"
        android:layout_height="150dp">

两者都显示得很好。

这里发生了什么?这是一个错误吗?

这是在 API24 模拟器中:

在此处输入图像描述

在 API23 模拟器中,相同的代码:

在此处输入图像描述

4

0 回答 0