Android LinearGradient XML

后端 未结 4 1945
时光说笑
时光说笑 2021-02-03 20:27

I\'m facing a small problem with the LinearGradient definition in XML. What I want is to use the constructor that accepts the array of colors and the array of positions.

<
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 20:46

    Unfortunately, the definition of GradientDrawable with XML does not allow more than three colors.

    Take a look at the official reference: http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html.

    Example:

    
    
        
        
    
    

    So, in your case you would add one more color using android:CenterColor. But for more than three colors, you'll even need to do it with Java.

提交回复
热议问题