美文网首页
Android Drawable .9图的放置位置

Android Drawable .9图的放置位置

作者: CalvinNing | 来源:发表于2019-07-29 14:06 被阅读0次

网上很多文章都说.9图放在drawable下,其实这种说法是错误的!!!
开发中一般都是设计切好.png图,开发者使用Android Studio Creat 9-patch file来生成.9.png后缀的.9图
具体.9图应该放在哪一个文件夹,取决于设计切的是几倍的图,
1倍图,放在drawable或者drawable-mdpi
2倍图,放在drawable-xdpi
3倍图,放在drawable-xxdpi
以此类推,对应放置。
网上普遍所说的放在drawable目录下,可能默认.9都是切的1倍图。
此外:drawable默认是1倍,同一张图片,放置在drawable和drawable-mdpi效果是一样的。

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal_l"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal_m"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal_h"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal_xx"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/d_normal_no"/>
同一张图片放置在不同drawable下

相关文章

网友评论

      本文标题:Android Drawable .9图的放置位置

      本文链接:https://www.haomeiwen.com/subject/adlbrctx.html