android - FragmentTransacation with slide in/out animation on >4 performance -
i'm trying implement fragment transaction slide in/out animation. i'm developing on minimum 14 sdk objectanimator option me (is there other way? translate animation not available understand).
the code simple:
animationview.java - wrapper class
public class animationview extends linearlayout { public animationview(context context, attributeset attrs) { super(context, attrs); } public float getyfraction() { return getheight(); } public void setyfraction(float yfraction) { final int height = this.getheight(); sety((height > 0) ? (yfraction * height) : -9999); } } slide in & out xml's
<?xml version="1.0" encoding="utf-8"?> <set> <objectanimator xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:propertyname="yfraction" android:valuetype="floattype" android:valuefrom="-1" android:valueto="0" android:duration="600"/> <?xml version="1.0" encoding="utf-8"?> <set> <objectanimator xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:propertyname="yfraction" android:valuetype="floattype" android:valuefrom="0" android:valueto="1" android:duration="600"/> animations works perfect, can see used custom property yfraction. performance bad... in tablets noticed horizontal white line (around 3 px height) during animation, in other smartphone device went slow (not duration slow flickering).
i found way fix if set valuefrom & valueto fit view dimension, it's not generic , need 0 1 generic views
would appreciate if can me or tell me if there's way implement on android 14 , up.
thanks.
try this:
if (mlastmenuweight > mmenuweight) { transaction.setcustomanimations(android.r.anim.slide_in_left, android.r.anim.slide_out_right); }else{transaction.setcustomanimations(r.anim.slide_in_right, r.anim.slide_out_left);}
Comments
Post a Comment