Reputation: 71
When clicking the Floating Action button in Android, how can I change the icon image from "Play" to "Pause"?
Upvotes: 0
Views: 1523
Reputation: 1033
Those resources as many others are available on the google design website and should be put on your res drawable folder.
Then as mentioned by Kristiyan Varbanov and Keshav setImageResource is best practice
fab.setImageResource(R.drawable.ic_pause_dark);
fab.setImageResource(R.drawable.ic_play_dark);
Upvotes: 0
Reputation: 2509
Changing FloatingActionButton source:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_full_sad, context.getTheme()));
} else {
floatingActionButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_full_sad));
}
Hope to help!
Upvotes: 1