0

我刚开始使用 Android 并正在制作启动画面。我试图将默认背景颜色更改为灰色,但显然我不能两次使用相同的属性。如何添加背景图像并更改背景颜色?谢谢。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/reddit_alien" 
    android:background="@color/grey"
    >
</LinearLayout>
4

2 回答 2

3

一种方法是使用 2 种布局。外部具有颜色背景,内部具有图像作为背景。

或者,您可以使用 xml 中的图层列表可绘制资源文件,该文件将一个图层定义为背景颜色,将另一个图层定义为背景图像。见这里:http: //developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

于 2012-10-07T16:24:59.520 回答
0

不,不可能两次声明相同的属性。她将它们图像作为背景或颜色。如果要设置颜色和背景图像,则创建两个视图。将底视图背景设置为彩色或图像,将顶视图背景设置为彩色或图像。

于 2012-10-07T16:22:50.113 回答