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)
It works for me.
public static int getColor(View v) {
if(Build.VERSION.SDK_INT>=11)
{
return ((ColorDrawable)v.getBackground()).getColor();
}
else
{
try
{
Field f=View.class.getDeclaredField("mState");
f.setAccessible(true);
Object mState=f.get(v);
Field f2=mState.getClass().getDeclaredField("mUseColor");
f2.setAccessible(true);
return (int) f2.get(mState);
}
catch (Exception e)
{
}
}
return 0;
}