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


当前回答

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

其他回答

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

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

我希望能够改变背景颜色为白色在我的 最简单的Android应用程序。

题目说的是最简单的方法,所以在这里。

在所有父视图中设置parentViewStyle。像大多数家长视图你的活动,片段和对话框。

<LinearLayout style="@style/parentViewStyle">

  ... other components inside

</LinearLayout>

把这个样式放在res>values>styles.xml中

<style name="parentViewStyle">
    <item name="android:layout_height">match_parent</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:background">@color/white</item> // set your color here.
    <item name="android:orientation">vertical</item>
</style>

通过这种方式,你不需要在未来改变背景颜色很多次。

你可以试试这种方法

android:background="@color/white"

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

@color /

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

android:background="@color/md_blue_900"