Say i have an xml
element like this:
<FrameLayout
android:id="@+id/login_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.2">
i want that alpha value 0.2
to be a variable. What is the "Android way" of making the value a variable? do i stick it in dimen.xml
? or does it even matter?
Would a proper way to do this be that i just create a file called transparency.xml
and then link it with android:alpha="@transparency/my_value"
?
You could do it as:
<resources>
<item name="alpha_value" format="float" type="dimen">0.2</item>
</resources>
This way alpha_value
will be in @dimen/
folder.
For more info, see the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With