Using a gradientDrawable with more than three colors set

前端 未结 5 939
孤独总比滥情好
孤独总比滥情好 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:25

    Using GradientDrawble we can achieve this

    GradientDrawable gradientInsta = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT,
                    new int[] {
                            Color.parseColor("#F9ED32"),
                            Color.parseColor("#F6C83F"),
                            Color.parseColor("#F2735F"), 
                            Color.parseColor("#EF3E73"),
                            Color.parseColor("#EE2A7B"),
                            Color.parseColor("#D22A8A"),
                            Color.parseColor("#8B2AB1"),
                            Color.parseColor("#1C2AEF"),
                            Color.parseColor("#002AFF”),
                            ContextCompat.getColor(MainActivity.this, R.color.colorPrimary)
            });
    findViewById(R.id.insta).setBackground(gradientInsta);
    

提交回复
热议问题