1 APP有时会使用到上下左右箭头这类内容一样,方向不同的图片,可以只预置一张上的箭头图标,下左右箭头可以使用代码旋转上箭头图标实现;这样只需预置一张图片,也减少了APP的大小。
在Google的官方文档中,有如下说明:
You can also omitresources that are only a rotated equivalent of another resource. The followingcode snippet provides an example of turning an "expand" arrow into a"collapse" arrow icon by simply rotating the original image 180degrees:
(https://developer.android.com/topic/performance/reduce-apk-size.html)
如下图两个图标箭头都是朝右的:
对应的XML代码如下:
<ImageView
android:layout_width="80dp"