天天看點

setBackgroundDrawable和setBackgroundColor的用法

1.設定背景圖檔,圖檔來源于drawable;

btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_pro));

2.轉換字元串為int(顔色);

btn.setBackgroundColor(Color.parseColor("#808080"));