繁体   English   中英

Android 7中的Androidx导航图标兼容性问题

[英]Androidx Navigation icon compatability issues in Android 7

我在我的应用程序和Android 8中使用com.google.android.material.appbar.AppBarLayout以及androidx.appcompat.widget.Toolbar它完美地工作但是我遇到了'汉堡包'菜单图标和'后退'的问题即使其他菜单图标显示正确,图标也只是在android 7(API 24和API 25)中显示为白色块。

汉堡包图标显示的位置。

汉堡包图标的样子

什么后退按钮看起来像。

什么后退按钮看起来像

我的应用栏布局:

<com.google.android.material.appbar.AppBarLayout
        android:id="@+id/activity_drawer_layout_app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />

    </com.google.android.material.appbar.AppBarLayout>

只需设置工具栏:

setSupportActionBar ( toolbar )

    actionBar?.setDisplayShowCustomEnabled(true)
    actionBar?.setDisplayShowCustomEnabled(true)
    actionBar?.setDisplayHomeAsUpEnabled(true)
    actionBar?.setDisplayShowHomeEnabled(true)
    actionBar?.setDisplayShowTitleEnabled(true)

当您使用材料库时,这是预期的结果。 我不知道默认情况下Android 8中的编译器如何覆盖材质主题设置。 如果使用材料库,则默认应用颜色。 有关详细信息, 查看https://material.io/design/color/applying-color-to-ui.html#usage
您将在该网站上了解有关材料库的所有信息。

您可以在主题中应用色调或背景颜色。

如果您无法找到问题 - >在工具栏中添加ImageView(用于后退按钮)

例如:

<Toolbar>
   <ImageView>
 </Toolbar>

暂无
暂无

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

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