1. 程式人生 > >android 中如何設定控制元件的字型和背景樣式

android 中如何設定控制元件的字型和背景樣式

1.設定背景圖片,圖片來源於drawable;
button.setBackgroundDrawable(getResources().getDrawable(R.drawable.search_label_click));
2.轉換字串為int(顏色);
button.setBackgroundColor(Color.parseColor("#F5F5DC"));
3.引用資源
button.setBackgroundResource(R.drawable.shapegray);
4.設定圖片背景色
button.setBackgroundColor(Color.parseColor("#C8C8C8"));