Android基础知识(一)颜色

xiaoxiao2021-02-27  179

//设置控件字体颜色

 

        btn_Mainmain.setTextColor(getResources().getColor(R.color.white));         btn_Mainmain.setTextColor(Color.rgb(247, 171, 0));         btn_Mainmain.setTextColor(Color.parseColor("#F5F5DC"));

//设置控件背景颜色          btn_Mainmain.setBackgroundColor(getResources().getColor(R.color.brown));         btn_Mainmain.setBackgroundColor(Color.rgb(247, 171, 0));         btn_Mainmain.setBackgroundColor(Color.parseColor("#F5F5DC")); //        设置控件背景图片         btn_Mainmain.setBackgroundResource(R.drawable.iv_title1); //      设置控件背景图片(已过时)         btn_Mainmain.setBackgroundDrawable(getResources().getDrawable(R.drawable.iv_title1));   //设置图片  imageView.setImageResource(R.mipmap.ic_launcher);

 

转载请注明原文地址: https://www.6miu.com/read-13009.html

最新回复(0)