天天看點

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); 

}