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


当前回答

你可以尝试在xml表:

android:background="@color/background_color"

其他回答

最简单的方法是在layout.xml或/res/layout/activity_main.xml的主节点中添加android:background="#FFFFFF":

<?xml version="1.0" encoding="utf-8"?>
   <TextView xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:padding="10dp"
       android:textSize="20sp" 
       android:background="#FFFFFF">
   </TextView>

你可以试试这种方法

android:background="@color/white"

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

@color /

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

android:background="@color/md_blue_900"

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

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

<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" />

希望这能有所帮助!