android - Custom Property animation not working on disabling animation -
i creating android application each fragment bind custom left right slide animation. achieved using custom property animation
(fractionlinearlayout.java
class given below). app has several fragment
, switching among these fragment followed right left slide animation. working perfect untill disable animation developer options testing purpose.
nothing appears when disable animations. can see logcats means app working perfect views not being loaded, (may be) because of custom properties fractiontranslationx , fractiontranslationy.
has gone through problem? in advance.
fractionlinearlayout.java: custom class animation
public class fractionlinearlayout extends linearlayout { displaymetrics matrics = getcontext().getresources().getdisplaymetrics(); public fractionlinearlayout(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); // todo auto-generated constructor stub } public fractionlinearlayout(context context) { super(context); // todo auto-generated constructor stub } public fractionlinearlayout(context context, attributeset attrs) { super(context, attrs); // todo auto-generated constructor stub } public float getfractiontranslationx() { return getwidth() > 0 ? super.gettranslationx() / getwidth() : float.max_value; } public void setfractiontranslationx(float translationx) { int width = getwidth(); super.settranslationx(width > 0 ? width * translationx : float.max_value); } public float getfractiontranslationy() { return getheight() > 0 ? super.gettranslationx() / getheight() : float.max_value; } public void setfractiontranslationy(float translationy) { int height = getheight(); super.settranslationy(height > 0 ? height * translationy : float.max_value); } public float getanimwidth() { return getlayoutparams().width; } public void setanimwidth(int animwidth) { getlayoutparams().width = animwidth; requestlayout(); } }
layout file of fragment:
fragment_main_layout.xml
<?xml version="1.0" encoding="utf-8"?> <com.bbi.views.fractionlinearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/esc_app_background" android:orientation="vertical"> ........... ........... </com.bbi.views.fractionlinearlayout>
custom animation xml file:
alide_in_left.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <objectanimator xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@integer/animation_time" android:propertyname="fractiontranslationx" android:valuefrom="1" android:valueto="0" android:valuetype="floattype" /> </set>
slide_out_left.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <objectanimator xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@integer/animation_time" android:propertyname="fractiontranslationx" android:valuefrom="0" android:valueto="-1" android:valuetype="floattype" /> </set>
code add fragment on activity:
getfragmentmanager().begintransaction() .setcustomanimations(r.anim.slide_in_left;, r.anim.slide_out_left) .replace(r.id.frametopcontainer, newstoolfragment) .commitallowingstateloss();
when replace com.views.fractionlinearlayout
linearlayout
in fragment_main_layout.xml, works fine(not animation obvious have disabled animation , removed property custom animation).
finally solved issue reading animation_scale
flag , removing setcustomanimations() method according that.
Comments
Post a Comment