我希望能够在我的android应用程序中以最简单的方式将背景颜色更改为白色。


当前回答

不仅仅是给Kotlin,当你写作的时候

@color /

你可以选择任何你想要的,快速而简单:

android:background="@color/md_blue_900"

其他回答

使用渐变背景的最好方法,因为它不会增加应用程序的大小,图像是android应用程序的毒药,所以尽量少使用它,而不是使用一种颜色作为背景,你可以在一个背景中使用多种颜色。

change_color setBackground getDrawable (R .[。purple_700);

当我尝试在点击时改变颜色时,这种方法是有效的。

不仅仅是给Kotlin,当你写作的时候

@color /

你可以选择任何你想要的,快速而简单:

android:background="@color/md_blue_900"

你可以试试这种方法

android:background="@color/white"

这个方法对我很管用:

RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.layout.rootLayout);
relativeLayout.setBackgroundColor(getResources().getColor(R.color.bg_color_2));

在布局xml中设置id

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rootLayout"
android:background="@color/background_color"

添加颜色值/color.xml

<color name="bg_color_2">#ffeef7f0</color>