gpt4 book ai didi

android - 将 MaterialDrawer 放在操作栏上方

转载 作者:太空狗 更新时间:2023-10-29 16:34:35 25 4
gpt4 key购买 nike

我怎么放MaterialDrawer ActionBar 上方的菜单?现在,当我打开 MaterialDrawer 菜单时,我的 ActionBar 就在它上面。 CSS 中有类似 Z-index 的东西吗? :D我的申请风格:

<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="background">@color/yellow_dark</item>
</style>
</resources>

我的 MaterialDrawer 初始化代码:

DrawerBuilder().withActivity(activity).addDrawerItems(...).withSelectedItem(-1).withTranslucentStatusBar(false).withActionBarDrawerToggle(false).build()

最佳答案

正如@igor_rb 已经指出的那样,这只有在您从 ActionBar 切换到 Toolbar 时才有可能。

在github上查看以下已经回答的问题 https://github.com/mikepenz/MaterialDrawer/issues/523 https://github.com/mikepenz/MaterialDrawer/issues/522 https://github.com/mikepenz/MaterialDrawer/issues/333

切换到 Toolbar 非常简单。


使用 AppCompatActivity在布局中定义工具栏

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp" />

Toolbar设置为SupportActionBar

// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

完成

关于android - 将 MaterialDrawer 放在操作栏上方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31959262/

25 4 0