Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should i store animation values?

I have some animation in my app, and they work fine. But I'd like to modify the behaviour (for example) between phone ui and tablet ui. So where should I set the row values (such as android:duration="xxx")?

[...]
<translate 
     android:duration="700"
     android:fromYDelta="90%p"
     android:toYDelta="0"/>
[...]

According to official documentation , there's no preferred place.

like image 820
Matteo A Avatar asked Jun 02 '13 08:06

Matteo A


1 Answers

You should store a value you wish to be different across screen sizes in the values folder. So for example you could have a folder called values for default and one say called values-sw600dp and in there specify a value for your duration which is only for a screen with a smallest width of 600dp.

Then in the values and values-sw600dp you can have a file called translation.xml or whatever describes the animation:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="duration">700</integer>
</resources>

And then where you do your animation xml:

<translate 
     android:duration="@integer/duration"
     android:fromYDelta="90%p"
     android:toYDelta="0"/>

This way you can specify different settings for different device sizes based on your folder names, just like you do with drawables.

like image 179
Neil Avatar answered Oct 04 '22 17:10

Neil