【问题标题】:In Android studio, all my icons are blurry and I can't figure out why在 Android Studio 中,我所有的图标都是模糊的,我不知道为什么
【发布时间】:2018-06-01 19:54:51
【问题描述】:

在 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>

【问题讨论】:

    标签: java android xml user-interface


    【解决方案1】:

    可能是因为您的图像资源密度不适合您的屏幕密度。 检查您的图像资源文件是否正确位于文件夹(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

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2022-08-19
        • 1970-01-01
        • 1970-01-01
        • 2017-05-21
        • 2019-06-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多