圆形图标图像模糊

时间:2016-03-03 13:15:54

标签: android android-layout android-imageview android-drawable android-shape

我创建了包含png图标的圆形绘图。根据Android Material指南,圆的直径为40dp,图标为24dp。最初我没有为left,right,top和bottom设置任何值,因为我假设内部图标项将保持24dp。但是,它会调整大小。然后我尝试使用宽度和高度属性将其强制为24dp,这似乎在AS的预览中起作用但对平板电脑没有影响。最后我设置了顶部,底部,左侧和右侧的值,如图所示。我使用8dp作为:(40-24)/ 2 = 8.

问题是圆圈内的图标看起来很模糊,好像它已调整大小但我对如何处理它感到茫然。也许有更好的方法将图标放在圆圈内。毕竟,这是一种非常常见的设计实践。

我已经在附加图像中的圆圈旁边放置了实际图标以进行比较,但遗憾的是由于图像压缩,很难区分清晰度,但我要说的是图像上的图像右边看起来像一个矢量,就像FAB中那样。

circle_grid.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">

            <solid
                android:color="@color/colorPrimary"/>

            <size
                android:width="40dp"
                android:height="40dp"/>
        </shape>
    </item>
    <item android:drawable="@drawable/ic_grid_on_white_24dp"
        android:top="8dp"
        android:bottom="8dp"
        android:left="8dp"
        android:right="8dp"
        android:gravity="center"/>
</layer-list>

fragment.xml之

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="@dimen/screen_edge_margin"
            android:layout_marginStart="@dimen/screen_edge_margin"
            android:src="@drawable/circle_grid" />

enter image description here

2 个答案:

答案 0 :(得分:1)

您使用的设备的DP组是什么?如果您的设备是hdpi DP,那么该图标的大小应为36 * 36。如果它在xhdpi组中,它应该具有48 * 48大小的像素。如果它在xxhdpi组中,则它的大小应为72 * 72。等等等等。我相信你只有一个尺寸的图标,这就是为什么显得模糊

答案 1 :(得分:0)

相关问题