Closed Narayane closed 9 years ago
Hi,
Animations are played while calling public methods:
Could you please clarify the action for which you need the animation to be played
Thank you
Hi,
it was the information which missed me. I had not even thought to check autocompletion for checking available methods ><.
You should add it in animation section of READ.md ;).
A suggestion: be able to set animation duration would be great !
Thanks !
Great, will add this into javadoc && README.md
For animation duration try this:
magicButton.getAnimationOnShow().setDuration(5000);
How can I animate it when scrolling through a list?
Hi davicdsalves,
Action Button supports 2 animation types: animation, which is played while showing the button and animation, which is played while hiding the button. By default neither show animation, nor hide animation are set. Animations are played only if set when you call methods:
Thus, in order to make animations working when scrolling you need to do 2 things:
Don't forget to set animations before calling these methods
Thanks for your response @shell-software, but don't you have a default implementation for this like other frameworks do? Since this behavior is expected to be used by many. I checked how floating-action-button from @shamaland was doing with it's ShowHideOnScroll, but decided to ask to see if I was missing some default listener here. Thanks again.
You're right, Action Button doesn't have default listeners for this.
This is so, because in fact such listeners are not the part of the Floating Action Button. Action Button gives you only a way to manage itself. It's up to you to decide how actually you need to manage it.
I agree with you @shell-software, I'm just looking for an implementation by someone else so I don't have to reinvent it, since I'm 100% sure someone else had to do it. Thank you, great job on the framework.
Hi shell-Software,
I have fragments in view pager and i have put fab in one specific fragment then now i have coded like this
floatingActionButton = (ActionButton ) rootView.findViewById(R.id.float_Button);
floatingActionButton.setType(ActionButton.Type.DEFAULT);
floatingActionButton.setImageResource(R.mipmap.ic_mode_edit_white_24dp);
floatingActionButton.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary));
floatingActionButton.setShowAnimation(ActionButton.Animations.JUMP_FROM_DOWN);
floatingActionButton.playShowAnimation();
but there is no animation playing when load the fragment in view pager ( while come to visible on this fragment)
where i have missed somethings? , Please let me know or else should add anything for play animation in view pager fragments, actually i need to play animation like jump from down and jump to down (page is visible and page is invisible state).
Thanks.
Hi jsiva001
This happens because animation is played before the action button is shown
Try setting the page listener and calling show() or hide() methods within its callbacks like this:
pager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionButton.show();
}
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
Hi,
I have no animation either if they are defined in xml or if they are defined programmatically.
I put a fab in a relative layout as you advise it, with a recycler view. All is inflated in a fragment.
All others features work well.
I don't understand what I do wrong.
Thanks.
fragment_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">
fragment onViewCreated
mFab = (FloatingActionButton) getSQActivity().findViewById(R.id.fragment_list_fab); mFab.setImageSize(24.0f); mFab.setImageDrawable(getResources().getDrawable(R.drawable.ic_add_white_24dp)); mFab.setAnimationOnShow(FloatingActionButton.Animations.ROLL_FROM_DOWN); mFab.setAnimationOnHide(FloatingActionButton.Animations.ROLL_TO_DOWN);