【问题标题】:How to put repeat images over a gradient shape in Android?如何在Android中将重复图像放在渐变形状上?
【发布时间】:2013-05-14 22:56:02
【问题描述】:

我在 xml 中有这段代码:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<gradient
    android:angle="90"
    android:endColor="#222288"
    android:startColor="#9966cc" />

如何在渐变上添加重复图像?用于 Android 项目的背景层。 类似这样的东西,但适用于 Android:

<style type="text/css">
body {
background-color: #666;
background-image:url(repeated_image.gif)
}
</style>

【问题讨论】:

    标签: android image gradient shape


    【解决方案1】:

    好的,我的答案是使用带有形状和位图的图层列表:

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

    <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <gradient
                android:angle="90"
                android:endColor="#222288"
                android:startColor="#9966cc" />
        </shape>
    </item>
    <item>
        <bitmap
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:src="@drawable/repeated_image"
            android:tileMode="repeat" />
    </item>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多