button颜色设置

来源:互联网 发布:雪梨淘宝店铺名称 编辑:程序博客网 时间:2024/05/17 02:02
1.用代码设置控件的颜色:
    int b =  getResources().getColor(R.drawable.blue);//得到配置文件里的颜色
    mButton.setTextColor(b);
    
2.设置空间的字体:
 方式一:mText.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf"));//设置字体
   注意:1.保证文件一定是ttf格式;2.放到assets/fonts目录下;3.如果找不到相应的字体不会报错,只是在运行的时候显示不出来
方式二: fontButton.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));//用内部支持的方式设置
原创粉丝点击