2015年5月7日 星期四

[Android] Element Image or background setting

Android
ib_camStatus=(ImageButton) listView.getChildAt(camIndex).findViewById(R.id.ib_camStatus);

// ib_camStatus.setBackgroundResource(R.drawable.blue_point);   //背景
ib_camStatus.setImageResource(R.drawable.blue_point);                   //前景

xml
android:background="@drawable/blue_point"           //背景
//android:background="@android:color/transparent"    //背景透明
android:src="@drawable/red_point"                         //前景
related reference http://www.bkjia.com/Androidjc/866967.html


=========================================
//下行為設定
background.setBackgroundColor(Color.RED);
//或是
background.setBackgroundColor(Color.parseColor("色碼")

沒有留言:

張貼留言