天天看点

android 控件的使用 备注

Android中字体加粗 一、英文在xml文件中使用android:textStyle=”bold”   二、但是不能将中文设置成粗体,将中文设置成粗体的方法是: 

TextView tv = (TextView)findViewById(R.id.TextView01);  TextPaint tp = tv.getPaint();  tp.setFakeBoldText(true);

还有一种比较假的办法,通过设置背影,伪装加粗

android:shadowColor=”#000000″

android:shadowDx=”0.2″ android:shadowDy=”0.0″ android:shadowRadius=”0.2″

效果图看看

android 控件的使用 备注

2、setBackgroundColor()无效的解决:

设置背景颜色setBackgroundColor(0x222222)是无效的,可以改为:

layout.setBackgroundColor(android.graphics.Color.parseColor("#009999"));

3、java实现android:layout_margin的功能。

如下:

LinearLayout layout= maplayout.get(type);

if(layout!=null){

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(

LinearLayout.LayoutParams.MATCH_PARENT, 

LinearLayout.LayoutParams.MATCH_PARENT);  

lp.setMargins(10, 10, 10, 10);  

layout.setLayoutParams(lp); 

}