Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法更改android xml文件中的背景颜色_Android - Fatal编程技术网

无法更改android xml文件中的背景颜色

无法更改android xml文件中的背景颜色,android,Android,每当我试图使用 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@android:color/SomeColor"> 我已清除该项目

每当我试图使用

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/SomeColor">
我已清除该项目,甚至多次重新启动它,但未能成功地消除错误。

请尝试以下操作:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/SomeColor">

希望这有帮助:)

现在你自己去提取xml文件,不要这样做,伙计,试着像这样在xml中提取颜色名称本身

<?xml version="1.0" encoding="utf-8"?>
    <resources>

         <color name="graycolor">#DCDCDC</color> 
         <color name="graycolor_press">#8B8B8B</color> 
    </resources>

#DCDC
#8b
那就这样取吧

<item android:drawable="@color/graycolor"/> 


您正在传递一个文件名,而您应该传递一个颜色名。您是否在Somecolor.xml中定义了颜色?该
Somecolor
存储在哪里?Somecolor是什么??尝试使用
@android:color/white
,如果您想要您的颜色,请在
color.xml
中添加该颜色,并将其用作
color/SomeColor
SomeColor
可能是火箭颜色!请将您的SomeColor.xml与资源文件的完整路径一起发布,我应该在布局内部还是外部设置#ffffff0000?我已经试过了,但得到了错误#dcdc#8by你采取相对布局UraG只需在你的可绘制文件夹中创建一个名为SomeColor.xml的xml,然后在你的主xml中设置相对背景,就像这样设置@android:color/graycolor“就是这样
<?xml version="1.0" encoding="utf-8"?>
    <resources>

         <color name="graycolor">#DCDCDC</color> 
         <color name="graycolor_press">#8B8B8B</color> 
    </resources>
<item android:drawable="@color/graycolor"/>