Reputation:
I need to show ripple on my button simply in the onCreate() of my activity. Of all the code I have scanned, ripple effect is only visible when button is pressed. Please guide me on how to show ripple by default without the button click.
Upvotes: 5
Views: 1685
Reputation: 10959
You still have to click button but programmatically. Use yourButton.performClick()
in your onCreate
method and make sure when you do this do not run code that is handle on click event for your button for that you can use one boolean
variable to check whether you are doing it programmatically or real action is perform
yourbutton clicklistener {
if(isprogrammatic){
// dont do anything
isprogrammatic = false
}
else{
// run your code
}
}
OnCreate
onCreate(Bundle..){ // your on create method
//yes it is programmatic
isprogrammatic = true;
yourbutton.performClick();
}
Upvotes: 1