当前位置 : 主页 > 手机开发 > android >

如何在android中创建自定义渐变?

来源:互联网 收集:自由互联 发布时间:2021-06-11
我想知道这种渐变颜色在 android中是否可行? 如果可能的话怎么样? http://www.techandall.com/wp-content/uploads/2013/10/techandall_mobile-analytics-UI-concept_preview1.jpg 谢谢, Bskania. int startColor=Color.parseC
我想知道这种渐变颜色在 android中是否可行?
如果可能的话怎么样?
http://www.techandall.com/wp-contenthttp://img.558idc.com/uploadfile/2013/10/techandall_mobile-analytics-UI-concept_preview1.jpg

谢谢,
Bskania.

int startColor=Color.parseColor("#a6c1de");
//you can add as many gradient colors as you want here
//and include it in the int array while initializing GradientDrawable 
int endColor=Color.parseColor("#aa82b7");
GradientDrawable mDrawable=new GradientDrawable(Orientation.LEFT_RIGHT, new int[] startColor,endColor});

LinearLayout mLayout=(LinearLayout)findViewById(R.id.your_id);
mLayout.setBackgroundDrawable(mDrawable);
网友评论