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


当前回答

另一种方法,进入布局->你的。xml文件->设计视图。然后进入组件树,选择你想要改变颜色的布局。在下面的组件树中有属性部分。在属性部分中选择背景(在图1中),然后单击图2。然后资源窗口将打开。从选择颜色菜单。然后选择你想要的颜色。在这里输入图像描述

其他回答

访问Activity_Main.xml 有设计视图/和文本视图。 选择文本视图 编写如下代码: android:背景= " @color / colorAccent”

如果你想为整个活动添加背景色

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#1de9b6"
    tools:context="com.example.abc.myapplication.MainActivity">
 </RelativeLayout>

如果你想使用背景视图

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Andrios"
    android:background="@color/colorAccent" />

希望这能有所帮助!

有时,文本与背景颜色相同,尝试用android:background="#CCCCCC"进入listview属性,你会看到。

change_color setBackground getDrawable (R .[。purple_700);

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

你可以试试这种方法

android:background="@color/white"