3

我尝试添加(径向)渐变作为背景(在 Android 4.0 中),作为背景图像或以编程方式,但它们都不起作用。我只能在模拟器中测试它,但我想在 4.0 设备上是一样的。

这些解决方案不起作用:

我想我尝试了更多的东西,但也许有人知道如何建立一个工作渐变作为背景?

我当前的代码如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SplashScreen">

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/desc_string"
        android:scaleType="centerCrop"
        android:src="@drawable/background_image" />

</RelativeLayout>

和 background_image.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/background_image"
    android:antialias="true"
    android:dither="true"
    android:src="@drawable/bg_portrait" />
4

2 回答 2

2

显然它只是模拟器。在真实设备上看起来不错。

于 2014-02-26T12:18:55.493 回答
0

试试这个链接伙伴,http://developer.android.com/reference/android/graphics/RadialGradient.html

覆盖绘制函数以使用画布对象绘制圆

于 2014-02-24T10:49:00.960 回答