我尝试添加(径向)渐变作为背景(在 Android 4.0 中),作为背景图像或以编程方式,但它们都不起作用。我只能在模拟器中测试它,但我想在 4.0 设备上是一样的。
这些解决方案不起作用:
- 放置在原始文件夹中。(禁用Android资源/图片/png优化)
- 制作具有抖动和抗锯齿的代理 xml,并将 png 的不透明度保存到 99%。(android:dither="true" 不抖动,怎么了?)
- 覆盖 onAttachedToWindow(Android:使用线性渐变作为背景看起来是带状的)
- 移动到 hdpi 文件夹(姜饼上的渐变)
- 以编程方式制作渐变(http://crazygui.wordpress.com/2010/09/05/high-quality-radial-gradient-in-android/)
我想我尝试了更多的东西,但也许有人知道如何建立一个工作渐变作为背景?
我当前的代码如下所示:
<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" />