繁体   English   中英

在 Android Studio 中,我所有的图标都很模糊,我不知道为什么

[英]In Android studio, all my icons are blurry and I can't figure out why

在 Android Studio 中,我的应用程序图标变得模糊,我不知道为什么。 我在草图中制作了所有图标。 有没有人在上传图标时有一个循序渐进的过程,以确保它们在所有手机尺寸下都清晰美观?

这是我的屏幕外观的链接: https : //imgur.com/a/MRcDg89

这是我的 XML 文件的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="com.example.leoconnelly.connexus.MainActivity">

<LinearLayout
    android:id="@+id/ll_learn"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center_vertical"
    android:layout_weight="1">

    <ImageButton
        android:id="@+id/learn"
        android:layout_width="match_parent"
        android:scaleType="centerCrop"
        android:src="@mipmap/learn_tab_button"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:padding="0dp"
        android:layout_weight="1"
        android:text="@string/learn"
        android:textSize="22sp"
       />





</LinearLayout>

<LinearLayout
    android:id="@+id/ll_find_care"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="center_vertical">

    <ImageButton
        android:id="@+id/find_care_button"
        android:layout_width="match_parent"
        android:scaleType="centerCrop"
        android:src="@mipmap/find_care_layer_button"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:padding="0dp"
        android:layout_weight="1"
        android:text="@string/learn"
        android:textSize="22sp" />

</LinearLayout>

<LinearLayout
    android:id="@+id/ll_talk_to_doctor"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="center_vertical">

    <ImageButton
        android:id="@+id/TalkToADocButton"

        android:layout_width="match_parent"
        android:scaleType="centerCrop"
        android:src="@mipmap/talk_to_a_doctor_new_font_button"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:padding="0dp"
        android:layout_weight="1"
        android:textSize="22sp" />


</LinearLayout>

<LinearLayout
    android:id="@+id/ll_visit_website"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="center_vertical">

    <ImageButton
        android:id="@+id/VisitWeb"
        android:layout_width="match_parent"
        android:scaleType="centerCrop"

        android:src="@mipmap/visit_web_icon_new_font_button"

        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:padding="0dp"
        android:layout_weight="1"
        android:textSize="22sp" />

</LinearLayout>

可能是因为您的图像资源密度不适合您的屏幕密度。 检查您的图像资源文件是否正确位于文件夹(mdpi、hdpi、xhdpi、xxhdpi、xxxhdpi)中。 最小的图像位于 mdpi 文件夹中,而 xxxhdpi 文件夹中的图像最大。 确保您将不同大小的相同图片按图像大小划分到文件夹(mdpi、hdpi、xhdpi、xxhdpi、xxxhdpi)中。

图像尺寸比例:

1) mdpi 文件夹中的图像是 1dp == 1px

2) hdpi 文件夹中的图像是 1dp == 1.5px

3) xhdpi 文件夹中的图像是 1dp == 2px

4) xxhdpi 文件夹中的图像是 1dp == 3px

按该比例调整最大图像的大小并放入正确的文件夹中

我也有同样的问题。 我通过使用 svg 格式图标来解决它。 使用 svg 格式的图标而不是 png。 PNG 格式不适用于较小的图标。 图标的密度是更改设备到设备。 所以使用SVG格式可以解决这个问题。

如果您将图标创建为 mipmap,它可能在很多地方都无法访问,例如 edittext 中的 drawableleft。 所以在这个地方 svg 格式的图标是最好的解决方案。

暂无
暂无

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

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