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)
Here is an additional option:
The way I solved this problem for my app was to define the colors in values/color.xml.
#ff0099cc
#ff1d1d1d
#ffffffff
...
@color/white
In the layout the TextView
has:
android:background="@color/textview_background"
If I want to get the background color in code I can just use:
getResources().getColor(R.color.textview_background)
This gives me a Color
object directly without worrying about getting the color from a Drawable
.