1. 程式人生 > >android開發:如何動態設定ImageView和button的背景

android開發:如何動態設定ImageView和button的背景

改變ImageView的背景

 Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.has_authorization, null);
 imv_authorization.setBackground(drawable);

改變button的背景顏色

btn_signed.setBackgroundColor(Color.parseColor("#7CFC00"));