android - Floating Action Button from support library custom animation (pre lollipop) -
i add rotate animation simulate circular progress bar time consuming operations started fab. working nicely on lollipop, animation not start on kitkat. glue? thanks.
- compilesdkversion 23
- buildtoolsversion '23.0.2'
- minsdkversion 16
- compile 'com.android.support:design:23.1.1
- compile 'com.android.support:support-v4:23.1.1'
layout.xml
<android.support.design.widget.floatingactionbutton android:id="@+id/review_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_gravity="center" android:layout_margin="@dimen/fab_margin_right" android:src="@drawable/ic_send_white_24dp" android:visibility="invisible" app:elevation="@dimen/elevation_high" tools:visibility="visible" />
myfragment.java
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.layout, container, false); button = (floatingactionbutton) view.findviewbyid(r.id.review_button); button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { startlongoperation(); dolongoperation(); } }); // delayed show button animation start button.postdelayed(new runnable() { @override public void run() { button.show(); } }, 250); return view; } /** disable form , show progress */ protected void startlongoperation() { button.setclickable(false); button.setbackgroundtintlist(colorstatelist.valueof(color.ltgray)); button.startanimation(animationutils.loadanimation(getactivity(), r.anim.rotate)); text.setenabled(false); ... } /** enable form , stop progress */ protected void stoplongoperation() { if (null != getactivity()) { button.setclickable(true); button.setbackgroundtintlist(colorstatelist.valueof(getresources().getcolor(r.color.zelena))); button.clearanimation(); text.setenabled(true); ... } } } public void dolongoperation() { ... // call stop animation when finished stoplongoperation(); }
Comments
Post a Comment