Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - where does alpha value go in values folder?

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" ?

like image 900
David T. Avatar asked Mar 03 '14 22:03

David T.


1 Answers

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.

like image 186
Kuba Spatny Avatar answered Sep 27 '22 21:09

Kuba Spatny