Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there such a method call "getBackgroundColor"?

Is there such a method call "getBackgroundColor" in TextView? if I got 2 textViews: tv1 and tv2 in one LinearLayout. What I did:tv1.setBackgroundColor(Color.BLUE)

Now if I wanna setBackgroundColor of tv2 as the same as tv1, how can I get the backgroundColor in tv1 first and then setBackgroundColor of tv2?

like image 754
Ricky Zheng Avatar asked Jan 13 '12 09:01

Ricky Zheng


1 Answers

There is a better solution than bourbons:

((ColorDrawable)view.getBackground()).getColor(); 

The advantage is we get an integer which is comparable to color enums given by Color class.

like image 105
kirsche40 Avatar answered Oct 03 '22 00:10

kirsche40