I'm using fragments and animations. I came out with this:
slide_in_up.xml :
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="y"
android:valueType="floatType"
android:valueFrom="600"
android:valueTo="0"
android:duration="500"/>
</set>
And this is where the animation is used:
public void showFirstFragment(View v) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.addToBackStack(null);
ft.setCustomAnimations(R.animator.slide_in_up, R.animator.slide_out_up);
ft.replace(R.id.fragmentContainer, firstFragment);
ft.commit();
}
It works, pretty well: the entering fragment shows up from the bottom while the previous one goes away up.
My problem is that i have a fixed dimension for the "vavlueFrom" tag in my animation XML (it is set to 600 because my fragment takes half the size of the screen and i'm thinking with 1200px resolution). With this fixed dimension when i have a screen resolution smaller than 1200px my fragment shows up a little bit late because it starts from more down (sorry if this sentence is wrong - I'm italian).
How can i set this dimension programmatically? I want to do something like: get screen resolution -> set "valueFrom" to half the y value.
Thaks in advance for your help!