넵 가능합니다.
<!-- test_round_shape.xml -->
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
</shape>
{ // 소스코드
StateListDrawable state = new StateListDrawable();
state.addState(new int[] { android.R.attr.state_pressed }, GetDrawable(R.drawable.test_round_shape, Color.Green));
state.addState(new int[] { -android.R.attr.state_pressed }, GetDrawable(R.drawable.test_round_shape, Color.Black));
ImageButton imageButton = (ImageButton) findViewById(R.id.test_image_btn);
imageButton .setBackgroundDrawable(state); // imageButton .setBackground(state);
}
public Drawable GetDrawable(int drawableResId, int color) {
Drawable drawable = getResources().getDrawable(drawableResId);
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
return drawable;
}
이렇게 하시면 소스코드상에서 color를 임의대로 주어 사용 할 수 있습니다.
위 코드에서는 Color.Green, Color.Black을 사용했는데,
사용 하고 싶으신 색상 int값을 저기다 바꿔 넣어 주시면 됩니다.