我想找到一个布局的背景颜色从我的code。有没有办法找到它?像 linearLayout.getBackgroundColor()
?
I want to find the background color of a Layout from my code. Is there any way to find it? something like linearLayout.getBackgroundColor()
?
这只能完成API 11+,如果你的背景是纯色的。
This can only be accomplished in API 11+ if your background is a solid color.
int color = Color.TRANSPARENT;
Drawable background = view.getBackground();
if (background instanceof ColorDrawable)
color = ((ColorDrawable) background).getColor();