Android 溢出菜单更改自定义工具栏布局
我有一个带有自定义Android 溢出菜单更改自定义工具栏布局,android,android-layout,android-appcompat,Android,Android Layout,Android Appcompat,我有一个带有自定义工具栏的活动: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:elevatio
工具栏的活动
:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/AppTheme"
app:contentInsetStart="0dp"
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
< !-- More content, including search box -->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
但在设备上看起来是这样的:
似乎溢出菜单正在更改布局。有什么办法可以解决这个问题吗?似乎有人问了一些类似的问题,但没有回答:
相反,我只是将搜索视图放在工具栏的下方,而不是其中。我匹配了背景色
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/AppTheme"
app:logo="@drawable/ic_restaurant_white_24px"
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
app:title="@string/app_name"
app:titleMarginStart="24dp"
app:titleTextColor="@android:color/white">
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/filter_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:padding="12dp">
您是否尝试过将SearchView Maxwidth设置为(Integer.MAX_VALUE)
?使用AppBarLayout
将是另一种解决方案-如果您想在用户开始滚动时隐藏标题或搜索,这将非常有用。