From 754478cb87421227a07698fe94094ef414e2c057 Mon Sep 17 00:00:00 2001 From: Uwe Trottmann Date: Wed, 6 Nov 2024 17:09:44 +0100 Subject: [PATCH] Guidelines: add note about using compat loading for vector drawables --- app/build.gradle.kts | 1 + docs/guidelines.md | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fc68ea694a..5bd5cc06bc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -39,6 +39,7 @@ android { minSdk = sgMinSdk targetSdk = sgTargetSdk + // Prevent plugin from generating PNGs, use compat loading instead https://developer.android.com/studio/write/vector-asset-studio#sloption vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/docs/guidelines.md b/docs/guidelines.md index b5c92aebd4..8b7363cce3 100644 --- a/docs/guidelines.md +++ b/docs/guidelines.md @@ -24,6 +24,13 @@ Some existing icons may still use the old Filled or the old non-rounded Outlined Name icon resource files like `ic___dp.xml`, for example `ic_event_control_24dp.xml`. +Load vector drawables [using compat loading](https://medium.com/androiddevelopers/using-vector-assets-in-android-apps-4318fd662eb9) +so they work (tinting) and do not crash (gradients) on all supported releases: + +- `Button`: use `ViewTools.setVectorDrawableTop`, ... +- `ImageView`, `ImageButton`: use `app:srcCompat` +- `TextView`: use `app:drawableStartCompat`, `app:drawableTopCompat`, ... + ## Click listeners The interface class is owned by the class that owns the views that trigger the click events, for