早上好!
我有一个关于线性布局的问题。 我在 XML 中设置了背景颜色,运行应用程序时背景正在更改。
但是如果我将代码放在应用程序的按钮侦听器中并进行更改,则没有任何变化 出于什么原因?
**线性布局 XML 代码
<LinearLayout
android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="@color/white"
>
**我的活动代码
page = (LinearLayout)findViewById(R.id.page);
page.setBackgroundColor(getResources().getColor(R.color.gray2));
page.setBackgroundResource(R.color.yellow);
当我尝试重新创建 scnerio 时,它正在工作。你能显示你为背景添加的listner代码吗