网上查找资料    记录学习

int strokeWidth = 5; // 3dp 边框宽度
int roundRadius = 15; // 8dp 圆角半径
int strokeColor = Color.parseColor("#2E3135");//边框颜色
int fillColor = Color.parseColor("#DFDFE0");//内部填充颜色 GradientDrawable gd = new GradientDrawable();//创建drawable
gd.setColor(fillColor);
gd.setCornerRadius(roundRadius);
gd.setStroke(strokeWidth, strokeColor);
setBackgroundDrawable(gd);
如果想设置Gradient的渐变色:
方法是改变GradientDrawable的创建方法:
int colors[] = { 0xff255779 , 0xff3e7492, 0xffa6c0cd };//分别为开始颜色,中间夜色,结束颜色

GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);

Android 用代码设置Shape,corners,Gradient的更多相关文章

  1. android 后台代码设置动画

    1.设置旋转动画 final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF, 0. ...

  2. Android中代码设置RadioButton的高端技巧

    不知道怎么起标题,就这样了. 目前主要讲两个方面内容: 代码方式 设置RadioButton的 android:button . android:background 等属性为 @null : 代码方 ...

  3. 代码设置Shape和Selector

    开发中经常需要使用Shape和Selector,如果每个都用xml设置的话,会占用apk大小,同时命名多了也会混乱,使用代码来设置会方便很多. 需要用到2个类:GradientDrawable和Sta ...

  4. Android -- java代码设置margin

    我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@dra ...

  5. Android 通过代码设置radiobutton不同方位图标的两种方法

    更换radiobutton中的图片在xml中很好设置,但对于初学者如何在代码中设置还是不容易找的.没法子,通过看原版api找到两个方法,setCompoundDrawables和setCompound ...

  6. android 通过代码设置drawableLeft

    /** * * @desc 设置左边图标 * @param @param drw * @return void */ public void setAlertLeftIcon(Drawable drw ...

  7. Android小代码——设置全屏

    1: public class MainActivity extends Activity { 2: @Override 3: public void onCreate(Bundle savedIns ...

  8. Android Studio如何设置代码自动提示

    在用Eclipse时候,你可以进行设置,设置成不管你输入任何字母,都能进行代码的提示,在Android Studio中也可以 设置,而且比Eclipse设置来的简单.当然如果你觉得代码自动提示会降低你 ...

  9. Android Studio如何设置自己主动提示代码

    同Eclipse时间,您可以设置,无论你是设置输入不管什么信,可以提示码,在Android Studio也可以 设置.并且比Eclipse设置来的简单. 当然假设你认为代码自己主动提示会减少你的代码水 ...

随机推荐

  1. 用CSS开启硬件加速来提高网站性能(转)

    翻译文章,原文地址:http://blog.teamtreehouse.com/increase-your-sites-performance-with-hardware-accelerated-cs ...

  2. Windows 2008 R2 64位上安装wamp失败的原因

    Exception Exception in module wampmanager.exe at 000F15A0... 因测试PHP程序需要,需要在windows系统上布署WAMP环境测试程序,对性 ...

  3. u3d_shader_surface_shader_1

    http://docs.unity3d.com/Manual/SL-SurfaceShaders.html 一:surface shader是啥 Writing shaders that intera ...

  4. C# String.split()用法小结。String.Split 方法 (String[], StringSplitOptions)

    split()首先是一个分隔符,它会把字符串按照split(' 字符')里的字符把字符串分割成数组,然后存给一个数组对象. 输出数组对象经常使用foreach或者for循环. 第一种方法 string ...

  5. nfs服务部署记录

    一.概念介绍NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布.功能是通过网络让不同的机器.不同的操作系统能 ...

  6. java多线程系类:基础篇:05线程的等待与唤醒

    概要 本章,会对线程等待/唤醒方法进行介绍.涉及到的内容包括:1. wait(), notify(), notifyAll()等方法介绍2. wait()和notify()3. wait(long t ...

  7. PHP PSR规范

    PHP PSR-1 基本代码规范(中文版)  http://segmentfault.com/a/1190000002521577PHP PSR-2 代码风格规范 (中文版)  http://segm ...

  8. IIS中ASP.NET安全配置

    1.禁止web中的DELETE.OPTIONS.PUT.HEAD和TRACE HTTP方法 请求方法是请求一定的Web页面的程序或用于特定的URL.可选用下列几种:GET: 请求指定的页面信息,并返回 ...

  9. 1003. Emergency

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  10. Spring Security授权 AccessDecisionManager

    Spring Security授权 AccessDecisionManager 博客分类: Security Spring   在前面那篇博客有一段配置: <http auto-config=& ...