1、打开Myeclipse的相关界面,在Window那里点击Preferences。
2、d出设置的对话框,选择General下的Appearance进入。
3、点击Colors and Fonts按钮,需要在右侧选择Java。
4、选择Java Editor Text Font,并点击Edit。
5、通过设置对应的参数以后,直接确定返回。
6、这样一来会看到图示的结果,即可设置JLabel的字体样式,大小,颜色了。
使用方法第一种是在listview中配置android:listSelector=”@drawable/list_item_bg”
第二种是在listview的item中添加属性android:background=”@drawable/list_item_bg”
第三种是java代码中使用:
Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg)
listview.setSelector(drawable)
注:列表有时候为黑的情况,需要加上下面的代码使其透明:
android:cacheColorHint="@android:color/transparent"
使用selector设置字体颜色
1
2
3
4
5
6
7
8
drawable/button_font.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="<a href="http://schemas.android.com/apk/res/android">" target="_blank">http://schemas.android.com/apk/res/android"></a>
<item android:state_selected="true" android:color="#FF0000" />
<item android:state_focused="true" android:color="#00FF00" />
<item android:state_pressed="true" android:color="#0000FF" />
<item android:color="#000000" />
</selector>
可以用setFont方法JButton jb=new JButton("设置字体大小和粗体")
Font f=new Font("华文行楷",Font.BOLD,20)//根据指定字体名称、样式和磅值大小,创建一个新 Font。
jb.setFont(f)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)