How to change color stroke and solid programmatically ?공부방/Android2020. 1. 27. 21:04
Table of Contents
Stroke color :
val drawable = view.background as GradientDrawable
drawable.setStroke(3, ContextCompat.getColor(context, R.color.colorWhite)) // width and stroke color
Solid color :
val drawable = view.background as GradientDrawable
drawable.setColor(ContextCompat.getColor(context, R.color.colorWhite)) // solid color
resource_border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorWhite"
/>
<corners android:radius="90dp" />
<stroke
android:width="1dp"
android:color="@color/color_green_sea" />
</shape>
반응형
'공부방 > Android' 카테고리의 다른 글
@soycrab :: 꿀맛코딩
행복한 코딩을 위하여!
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!