user2737037
user2737037

Reputation: 1157

Get button-clicked color of theme

Is there a way, to get the button-clicked colour based on the current theme? The best would be a xml @color that I can use.
I am planning to use this colour for my ImageButtons when pressed.

Upvotes: 1

Views: 70

Answers (2)

user2737037
user2737037

Reputation: 1157

I have found an workaround. When you set this as background, the colour is changed automatically by the operating system according to the theme as if it was a button.

android:background="?android:attr/selectableItemBackground"

If you want to use the attribute on pre API 11 devices you can use:

android:background="?attr/selectableItemBackground"

Upvotes: 0

Danny Buonocore
Danny Buonocore

Reputation: 3777

If you just want to get a specific color one time, you could hold the button down on your device and screenshot it. Then open the image in MS Paint or something to grab the colors used.

Upvotes: 1

Related Questions