Yousha Aleayoub
Yousha Aleayoub

Reputation: 5618

How to GET Layout's background color?

How to GET Layout's background color ?

For example i have a MainActivity and FormOne.xml and FormTwo.xml as layout. Now i want to GET background color of FormTwo.xml in MainActivity...

Is it possible? and how

Thanks in advance.

Upvotes: 0

Views: 374

Answers (1)

As you can find th answer in another question (Android: How to get background color of Activity in Java?).

TypedArray array = getTheme().obtainStyledAttributes(new int[] {  
    android.R.attr.colorBackground, 
    android.R.attr.textColorPrimary, 
}); 
int backgroundColor = array.getColor(0, 0xFF00FF); 
int textColor = array.getColor(1, 0xFF00FF); 
array.recycle();

Upvotes: 2

Related Questions