[译]Multi-Gradient shape
来源:互联网 发布:cocos2dx mac环境搭建 编辑:程序博客网 时间:2024/06/03 21:44
原文链接:https://stackoverflow.com/questions/4381033/multi-gradient-shapes
需求:
给定n个颜色,每种颜色需要按照比例设置为view的背景。
解决:
Button theButton = (Button)findViewById(R.id.thebutton);ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient lg = new LinearGradient(0, 0, 0, theButton.getHeight(), new int[] { Color.LIGHT_GREEN, Color.WHITE, Color.MID_GREEN, Color.DARK_GREEN }, //substitute the correct colors for these new float[] { 0, 0.45f, 0.55f, 1 }, Shader.TileMode.REPEAT); return lg; }};PaintDrawable p = new PaintDrawable();p.setShape(new RectShape());p.setShaderFactory(sf);theButton.setBackground((Drawable)p);
阅读全文
0 0
- [译]Multi-Gradient shape
- Shape的gradient属性
- android shape 之gradient
- Android (shape,gradient)详解
- shape.gradient使用示例
- Android (shape,gradient)使用总结
- Android (shape,gradient)使用总结
- Android (shape,gradient)使用总结
- Android (shape,gradient)使用总结
- shape中gradient属性介绍
- shape中gradient属性介绍
- Android背景渐变色(shape,gradient)的实现,gradient
- 1. android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- android 背景渐变色(shape,gradient)
- Java---集合初入门
- Git查看、删除、重命名远程分支和tag
- 求不大于n的正整数的阶乘的和
- 文件上传方式2
- 不同用户设置ssh信任关系不输入密码执行scp 命令
- [译]Multi-Gradient shape
- Tarjin算法求桥和割点模板
- Python基于pandas的数据处理
- CoordinatorLayout 上的一些布局技巧
- Java-MongoDB入门级小程序,方便直接上手使用
- 域名解析相关备忘
- greendao的使用
- 求100-200之间素数的三种方法
- ORM系列之三:Dapper