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.
2 Answers
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.
3 Comments
krossovochkin
Instead of such mmmm... actions, you can just use hierarchy viewer. developer.android.com/tools/help/hierarchy-viewer.html But I thought, that question is about getting color programmatically, isn't it?
Danny Buonocore
Oh that's neat. Yeah that's probably the better way to do it
user2737037
Yes @krossovochkin, I want to get it programmatically. Either in xml or in java.
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"