1

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 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
Oh that's neat. Yeah that's probably the better way to do it
Yes @krossovochkin, I want to get it programmatically. Either in xml or in java.
0

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" 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.