【问题标题】:android studio - radial gradient not working on phoneandroid studio - 径向渐变在手机上不起作用
【发布时间】:2016-10-06 19:00:03
【问题描述】:

我正在尝试在我的应用上设置径向线性背景。我目前正在使用它进行预览,但是当我在三星 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>

知道有什么问题吗?

【问题讨论】:

    标签: android-studio background samsung-mobile linear-gradients


    【解决方案1】:

    这是一个错误。在这里检查:https://code.google.com/p/android/issues/detail?id=77862

    【讨论】:

      【解决方案2】:

      我找到了另一种解决方法 - 在代码中设置渐变背景:

      findViewById(R.id.bg).setBackground(ContextCompat.getDrawable(context,R.drawable.bg_gradient));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-06
        • 2011-08-15
        • 1970-01-01
        相关资源
        最近更新 更多