Skip to content

Commit

Permalink
Guidelines: add note about using compat loading for vector drawables
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Nov 7, 2024
1 parent 60a4f79 commit 754478c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 7 additions & 0 deletions docs/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<name>_<tint>_<size>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
Expand Down

0 comments on commit 754478c

Please # to comment.