Using a gradientDrawable with more than three colors set

前端 未结 5 938
孤独总比滥情好
孤独总比滥情好 2020-12-29 06:40

According to what I\'ve read, you can use a gradientDrawable and have three colors set for it, for example:



        
5条回答
  •  时光取名叫无心
    2020-12-29 07:23

    In Kotlin you can do it like this:

    replace color1,2,..n with your color values

                     //Create Gradient 
                    val gradientDrawable = GradientDrawable(
                        GradientDrawable.Orientation.TOP_BOTTOM,
                        intArrayOf(color1,color1 ,color1, colorn)
                    );
                    gradientDrawable.cornerRadius = 0f;
    

提交回复
热议问题