안드로이드/레이아웃
안드로이드(Android) - Drawable Shape Color Change
JY-Dev
2020. 9. 7. 16:55
[OverView]
이번에는 Drawable Shape의 Solid 색상을 변경하는 방법에 대해 알아보겠습니다.
[Code]
var drawable = ContextCompat.getDrawable(this,R.drawable.circle_gray) as GradientDrawable
drawable.setColor(ContextCompat.getColor(this,R.color.colorAccent))
imageView.setImageDrawable(drawable)
drawable을 GradientDrawable로 캐스팅한후 setColor를 통해 원하는 색상을 넣어주시면 됩니다.