'How to change <item> width and height from drawable in xml programmatically?
I have created a drawable resource as a layer list. Inside my drawable resource I have a PNG image as drawable which I want to be set programmatically and not statically as seen below:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Other items -->
<item>
<!-- ... -->
<item
android:drawable="@drawable/my_drawable"
android:gravity="center"
android:width="32dp" <!-- want to set it programmatically -->
android:height="32dp"> <!-- want to set it programmatically -->
</item>
</layer-list>
I know that the above approach is only available for SDK >= 22. Is this possible in Android, best for SDK >= 22?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
