一. Tint著色器
Tint能夠?qū)崿F(xiàn)圖片變色,利用tint顯示不同顏色的圖片,原本需要多張相同圖片不同顏色的情況牵现,能夠減少apk的體積
使用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--原始圖片-->
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="@drawable/ic_favorite_black_24dp"/>
<!--著色圖片-->
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="@drawable/ic_favorite_black_24dp"
android:tint="@color/captcha_fault"/>
</LinearLayout>
image.png
selector中tint使用
<!--selector點(diǎn)擊-->
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:src="@drawable/selector_test"
android:tint="@color/selector_tint_color"/>
selector_test.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_favorite_black_24dp" android:state_pressed="true"/>
<item android:drawable="@drawable/ic_favorite_black_24dp"/>
</selector>
main_big_bottom_dcd261.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/main_big_bottom_dcd261" android:state_pressed="true"/>
<item android:color="@color/main_commend"/>
</selector>
APK優(yōu)化(一)之SVG--------------解決大量的套圖問(wèn)題
APK優(yōu)化(二)之Tint著色器-------------減少apk體積
APK優(yōu)化(三)之資源打包配置----resources.arsc
APK優(yōu)化(四)之.so動(dòng)態(tài)庫(kù)打包配置
APK優(yōu)化(五)之移除無(wú)用資源铐懊,物理刪除
APK優(yōu)化(六)之代碼混淆
APK優(yōu)化(七)之啟用shrinkResources資源縮減 ,不需要物理上的刪除
APK優(yōu)化(八)之啟用webp轉(zhuǎn)換插件-----圖片變小
APK優(yōu)化(九)之資源res文件混淆和7ZIP壓縮