android - Android drawable图标在不同分辨率下看起来有所不同

我的项目中有一个可绘制的图层列表:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/circle_border_ok"
        android:gravity="fill"/>
    <item android:drawable="@drawable/ic_logger_data_read"
        android:gravity="center"/>
</layer-list>

circe_border_ok看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke
        android:width="2dp"
        android:color="@color/colorOk"/>
    <size
        android:width="@dimen/icon_size"
        android:height="@dimen/icon_size"/>
</shape>

ic_logger_data_read看起来像这样:

<vector android:height="30dp" android:viewportHeight="194.65"
    android:viewportWidth="111.11" android:width="11dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#231f20" android:pathData="M31.58,117.82a0.8,0.8 0,0 0,-0.8 0.8h0v14.23a0.79,0.79 0,0 0,0.77 0.81L45.79,133.66a0.8,0.8 0,0 0,0.8 -0.8h0v-14.2a0.82,0.82 0,0 0,-0.8 -0.82L31.58,117.84ZM65.28,117.82a0.81,0.81 0,0 0,-0.8 0.82h0v14.21a0.79,0.79 0,0 0,0.77 0.81L79.5,133.66a0.81,0.81 0,0 0,0.81 -0.81v-14.2a0.84,0.84 0,0 0,-0.81 -0.82ZM49.17,118.64v4.79L54,123.43v4.74L49.18,128.17v9.55L44.42,137.72v3.16h-8v-4.75L31.59,136.13v4.78h4.75v8.83h4.8v-4h4.43v-3.17h3.62v-4.83L54,137.74v2.41h9.51L63.51,152L58.73,152v-4.72L54,147.28v-4.77L49.16,142.51v4.78L54,147.29v4.73L49.21,152.02L49.21,166L54,166v-4.59h4.73v-4.6h4.8v-4.69h4.72L68.25,145L73,145v4.74h6.45v-4.79L73,144.95v-4.78L63.53,140.17v-4.79L54,135.38v-7.2h8.23v-4.79L54,123.39v-4.75ZM32.39,119.45L45,119.45v12.6L32.35,132.05v-12.6ZM66.09,119.45L78.7,119.45v12.6L66.09,132.05ZM34.2,121.26v9h9v-9ZM67.92,121.26v9h9v-9ZM73.07,135.37v4.8h4.78v-4.8ZM31.58,151a0.8,0.8 0,0 0,-0.8 0.8h0L30.78,166a0.79,0.79 0,0 0,0.79 0.81L45.79,166.81a0.8,0.8 0,0 0,0.8 -0.8h0v-14.2a0.82,0.82 0,0 0,-0.8 -0.81ZM54,152.13h4.73v4.52L54,156.65ZM32.35,152.63L45,152.63v12.61L32.35,165.24ZM65.46,154.27v4.79L70,159.06v7.19h9.5v-4.8h-4.7v-7.16L70.31,154.29ZM34.16,154.44v9h9v-9ZM58.73,161.44v4.8h4.79v-4.8Z"/>
    <path android:fillColor="#231f20" android:pathData="M73.53,28.84h2.42v6.15h-2.42z"/>
    <path android:fillColor="#231f20" android:pathData="M76.46,35.49L73,35.49L73,28.34h3.43ZM74.03,34.49h1.43L75.46,29.34L74,29.34Z"/>
    <path android:fillColor="#231f20" android:pathData="M54.04,28.84h2.43v6.15h-2.43z"/>
    <path android:fillColor="#231f20" android:pathData="M57,35.49L53.52,35.49L53.52,28.34L57,28.34ZM54.57,34.49L56,34.49L56,29.34L54.52,29.34Z"/>
    <path android:fillColor="#231f20" android:pathData="M32.12,28.84h2.42v6.15h-2.42z"/>
    <path android:fillColor="#231f20" android:pathData="M35,35.49h-3.4L31.6,28.34L35,28.34ZM32.58,34.49L34,34.49L34,29.34h-1.4Z"/>
    <path android:fillColor="#231f20" android:pathData="M54.39,99.57a9.27,9.27 0,0 1,-3.78 -17.74l1.23,2.73a6.28,6.28 0,1 0,5.1 0l1.22,-2.74a9.27,9.27 0,0 1,-3.77 17.75Z"/>
    <path android:fillColor="#231f20" android:pathData="M52.89,77.03h3v13.6h-3z"/>
    <path android:fillColor="#231f20" android:pathData="M55.54,194.65c-16.87,0 -28.79,-9.19 -32,-12s-12.8,-11.09 -19,-29.42C0.1,140.11 1,81.52 1,78.23c0,-1.16 -0.6,-17 -0.87,-33.13C-0.41,10.72 0.77,8.86 1.48,7.72 2.59,6 5.54,3.72 18.7,2A293.16,293.16 0,0 1,55.58 0c18.21,0 49.43,1 54,7.58 0.74,1.08 2,2.88 1.36,37.36 -0.29,16.14 -0.88,32.07 -0.92,33.21 0,3.25 0.73,60.52 -3.47,74.94 -5,17.3 -14,25.47 -19.39,30.35S72.81,194.65 55.54,194.65ZM5.72,10.29C4.48,14.59 4.94,48.16 6,78v0.13c0,0.61 -1,61 3.23,73.43 5.17,15.27 12.48,22.86 17.54,27.24 2.92,2.53 13.63,10.79 28.76,10.79 15.36,0 23.14,-5.28 28.21,-9.88s13.31,-12.1 18,-28c4,-13.81 3.28,-72.94 3.27,-73.53v-0.13c1.12,-29.85 1.61,-63.42 0.35,-67.71C103.76,8.8 92.12,5 55.59,5 22,5 7.68,8.5 5.72,10.29Z"/>
</vector>

我已经尝试过使用图层列表中的重力设置,但是在不同的手机上绘制图标的方式有所不同。

在分辨率为720x1280的Android 5.1手机上,该图标最终被绘制如下:

在此处输入图片说明

在分辨率为1080x2160的LG Q6上,它看起来像这样(我希望它看起来像):

在此处输入图片说明

我怀疑这不一定与屏幕大小有关,而是可能仅适用于高于Android 5.1的SDK的指令,但我不知道。

转载请注明来自askonline.tech,本文标题:android - Android drawable图标在不同分辨率下看起来有所不同


 Top