这是我的XML代码:是否可以从Activity文件为LinearLayout设置背景?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/blue"
android:gravity="center">
可以从我的活动文件中设置的颜色?
例如,我可以做到这一点对一个按钮:
ImageButton x = (ImageButton) this.findViewById(R.id.btn1);
x.setBackgroundColor(color);
但是我怎样才能获得我的Activity类中的LiniarLayout对象? – Andreea
与您在示例中获得ImageButton的方式相同。我以为你知道这一点。看看ADR的答案。 – Rad