我试图在我的应用上设置径向线性背景。我目前正在进行预览,但是当我在三星Galaxy S4上运行我的应用程序时,它会使整个背景成为起始颜色。
预览外观:
三星Galaxy S4外观:
这是我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:type="radial"
android:startColor="#f3e5f5"
android:endColor="#9c27b0"
android:gradientRadius="600"
android:angle="270"
android:centerX="50%"
android:centerY="20%"/>
</shape>
知道什么是错的吗?
答案 0 :(得分:0)
这是一个错误。请在此处查看:https://code.google.com/p/android/issues/detail?id=77862
答案 1 :(得分:0)
我找到了另一种解决方法 - 在代码中设置渐变背景:
findViewById(R.id.bg).setBackground(ContextCompat.getDrawable(context,R.drawable.bg_gradient));