I have a timer, and i want to trigger a ripple effect every second.
I don't have a problem with the ripple effect, i can't find a way to trigger it on another event except the user's onClick.
Is it possible?
I guess you want to acheive something like this?
https://github.com/skyfishjy/android-ripple-background
Related
I want to add this ripple effect when card view is swipe.
How i can achieve this?
Here's the video i'm questioning, nowhere can't find answer.
https://drive.google.com/file/d/0B1vNFnrquuFFOVJPSlJKY0I1bDdYY21mYjRqQlFqWFYwZHl3/view?usp=sharing
I already maked swipeAdapter i just need that ripple effect when swiping is started. Here's my code:
pastebin.com/zGfmmbwm, and interface for listener, pastebin.com/9JzX1yhC
, do i need to create some interface for listener when swiping ?
Please refer to https://github.com/daimajia/AndroidSwipeLayout.
If u get stuck, please feel free to comment.
i just need that ripple effect when swiping is started
There can be so many ways it can be done but the simplest one is to add ripple background to your CardView, that is, when user touches the cardView the ripple will be shown.
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"/>
The logic is whether the user wants to just see the content or want to swipe, he has to touch the Card, which it turn will add the ripple effect.
I want to be able to show to my users whenever they recieve a new location update in my app.
So, whenever onRecieve() is called in my activity I want a imageView to animate a single ripple effect.
Ive tried to find a appropriate librabry that can do this easily but with no success.
Given my requirements can anyone point me in the right direction or suggest a good way to accomplish this?
Using this library https://github.com/skyfishjy/android-ripple-background i couldnt make a single ripple effect.. it never stops until i call stopRippleAnimation();
Edit: Using a valueanimator was a perfect solution for this
Call stopRippleAnimation after the ripple animation duration.
Also you can easily perform this animation using valueAnimator, Fadeout and scale using the values between 0 and 1.
I'm observing a bug with ripple animation on a button in Android. Basically, I have a ViewGroup, call it ButtonContainer that contains 2 buttons, call them OkButton and CancelButton. When the user clicks on CancelButton, I want to hide ButtonContainer by setting it's visibility to GONE. But this is causing a side effect, that the ripple animation on CancelButton is queued, but never played, and it plays the next time ButtonContainer becomes visible. This seems to happen because button's OnClickListener is fired before the ripple animation has a chance to play. This article describes this exact bug and shows how exactly the view behaves: link
The author suggests a workaround, but I'm wondering, is there a way to have the OnClickListener get fired after ripple animation on a button is played?
The short answer: not really and according to the Material guidelines (AFAIK) you shouldn't delay the onClick execution in such a way. In my opinion it would result in pretty poor UX - I like my buttons snappy and I don't like waiting for fancy animations.
The medium-length semi-answer: you could do a quick hack and wrap the meat of your onClick logic in a .postDelayed(...) call with a good enough delay. With a proper delay, the action would happen after the ripple. It is a hack, it is brittle and I would advise you against this solution.
The long answer: you can actually determine if the Ripple has finished animating, though that path is a bit complicated. Ripple is a Drawable, and as all animating Drawables, it tells its View when to do animation (and when to finish it) with a callback. You could tap into this callback to tell when the animation actually finished.
E.g. you could implement your own callback for this that forwards all calls to the Ripple's hosting ViewGroup and also tell you when the animation has finished so you can do business.
As the bottom line, I think that you should either:
Solve this problem as the article does that you linked
Just forget about the Ripple effect in this case if that's an option.
I don't know how exactly this type of buttons is called that's why I can't even google about it.
You use that button to unlock phone - tap on it and move from left to right.
I'd like to add same button in my app. How to do it?
You should use SeekBar to achieve what you want. http://developer.android.com/reference/android/widget/SeekBar.html
Here is a good example
http://www.techrepublic.com/blog/app-builder/androids-seekbar-your-way/943
Try this for a library
https://github.com/sitepoint-editors/SwipeButtonExample
and this for a DIY
https://rightclicksolutions.wordpress.com/2014/04/09/android-slide-to-unlock-like-ios-mb-slider-slider/
You can overide onTouch() and change the location of the button acording to the x position. and when you lift the finger you can overide onUp() (im not sure thats the name of the method) and create an animation that will lead the button back to its place.
From your question I get that you might think its a button you can simply add from a list of buttons, well, its not. you need to manualy create it.
I have a button that plays a sound clip when it is pressed. I would like the button to appear pressed during the duration of the sound clip. By that, I mean that I would like the button to take on the default pressed-button appearance while the sound is playing. How can I implement this? I have tried using a number of things in the onClickListener (such as setSelected, requestFocus, etc), but none of those do the trick. I have also tried changing the onClickListener to an onTouchListener, again with no dice. Am I wrong in assuming that there must be a way to simply set the button image to appear pressed? (BTW, the button object is of type Button, not ImageButton).
Thanks for any advice!
Please see this question. It details a couple of different ways this can be done.
Lookup 'selector' drawables and let android take care of this for you.