显示像素化的 Android 抽屉导航项目图标

标签 android android-layout navigation-drawer android-icons

我已经创建了抽屉导航,我试图在我的抽屉导航菜单中的项目旁边显示一个图标,但是我在抽屉导航上的图标显示模糊和像素化,我的图标大小是 72x72,我会分享我的代码和屏幕截图

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_dash_board"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_dash_board"
        app:menu="@menu/activity_dashboard_drawer" />

</android.support.v4.widget.DrawerLayout>

我的菜单项 xml 是

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="none">
        <item
            android:id="@+id/nav_Scheduled"
            android:icon="@drawable/ic_schedule_black_24dp"
            android:title="Scheduled" />
        <item
            android:id="@+id/nav_Completed"
            android:icon="@drawable/ic_done_black_24dp"
            android:title="Completed" />
        <item
            android:id="@+id/nav_Pending"
            android:icon="@drawable/ic_remove_circle_black_24dp"
            android:title="Pending" />
        <item
            android:id="@+id/nav_inprogress"
            android:icon="@drawable/ic_replay_30_black_24dp"
            android:title="In-Progress" />

        <item
            android:id="@+id/nav_Settings"
            android:icon="@drawable/ic_settings_black_24dp"
            android:title="Settings" />
        <item
            android:id="@+id/nav_Support"
            android:icon="@drawable/ic_info_outline_black_24dp"
            android:title="Support" />
        <item
            android:id="@+id/nav_logout"
            android:icon="@drawable/ic_settings_power_black_24dp"
            android:title="Logout" />
    </group>


</menu>

enter image description here

最佳答案

所有 Drawable 文件夹的导航图标大小应该不同,以避免模糊、像素相关的问题。 所有可绘制文件夹的导航图标大小如下,

->mdpi:24 x 24 像素

->hdpi:36 x 36 像素

->xhdpi : 48 x 48 像素

->xxhdpi : 72 x 72 像素

->xxxhdpi : 96 x 96 像素

关于显示像素化的 Android 抽屉导航项目图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40479604/

相关文章:

android - 在 Google Play 上找不到应用,但可以从 URL 中看到它

BLE芯片正在计算时Android低功耗蓝牙连接超时

android - 在android中请求权限代码

android - 在状态栏中仅显示小图标而不显示通知

未设置 Android 导航 java.language.IllegalStateException fragment 类

android - 如何防止 Volley Library 在完成请求后在 Log 中显示链接?

java - 将变量应用于 Retrofit HTTP 方法注释

java - 如何将布局作为函数参数传递

java - 抽屉导航 - 带 ListView 的标题 View

android - 如何将 View 扩展到抽屉布局之外?