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));//用内部支持的方式设置
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));//用内部支持的方式设置