Android studio android studio-径向渐变不适用于手机
我正在尝试在我的应用程序上设置径向线性背景。我目前正在预览,但当我在三星Galaxy S4上运行我的应用程序时,整个背景只是开始颜色 预览外观: 三星Galaxy S4外观: 这是我的XML文件:Android studio android studio-径向渐变不适用于手机,android-studio,background,samsung-mobile,linear-gradients,Android Studio,Background,Samsung Mobile,Linear Gradients,我正在尝试在我的应用程序上设置径向线性背景。我目前正在预览,但当我在三星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" >
<?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>
知道怎么回事吗?这是个bug。检查这里:我找到了另一个解决方法-在代码中设置渐变背景:
findViewById(R.id.bg).setBackground(ContextCompat.getDrawable(context,R.drawable.bg_gradient));