Skip to content

Commit b95f087

Browse files
Merge pull request #6 from mashik424/master
Add an attribute to set the border width
2 parents db8d454 + 3f83e52 commit b95f087

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ dependencies {
6060
| `app:custom_component_editText_bg_color` | Set EditText background color | `R.color.colorPrimary` |
6161
| `app:custom_component_maxLength` | Set EditText maxLength | `99` |
6262
| `android:inputType` | Set EditText inputType | `EditorInfo.TYPE_TEXT_VARIATION_NORMAL` |
63+
| `app:custom_component_border_width` | Set Outlined border width | `1` |
6364

6465
### Usage
6566
------------------------

customedittextoutlinedborder/src/main/java/com/simform/customcomponent/SSCustomEdittextOutlinedBorder.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class SSCustomEdittextOutlinedBorder @JvmOverloads constructor(context: Context,
2828
private var titleErrorColor = ContextCompat.getColor(context, R.color.color_error)
2929
private var borderColor = ContextCompat.getColor(context, R.color.color_warm_grey)
3030
private var borderErrorColor = ContextCompat.getColor(context, R.color.color_error)
31+
private var borderWidth = 1
3132

3233
val getTextValue: String
3334
get() {
@@ -54,6 +55,7 @@ class SSCustomEdittextOutlinedBorder @JvmOverloads constructor(context: Context,
5455
titleErrorColor = typedArray.getColor(R.styleable.custom_component_attributes_custom_component_title_error_color, ContextCompat.getColor(context, R.color.color_error))
5556
borderColor = typedArray.getColor(R.styleable.custom_component_attributes_custom_component_border_color, ContextCompat.getColor(context, R.color.color_warm_grey))
5657
borderErrorColor = typedArray.getColor(R.styleable.custom_component_attributes_custom_component_border_error_color, ContextCompat.getColor(context, R.color.color_error))
58+
borderWidth = typedArray.getInt(R.styleable.custom_component_attributes_custom_component_border_width, 1)
5759

5860
setTitle(title as String)
5961
setEditTextHint(editTextHint as String)
@@ -130,12 +132,12 @@ class SSCustomEdittextOutlinedBorder @JvmOverloads constructor(context: Context,
130132
val dcs = drawable.constantState as DrawableContainerState?
131133
val drawableItems = dcs!!.children
132134
val gradientDrawableChecked = drawableItems[0] as GradientDrawable
133-
gradientDrawableChecked.setStroke(2, colorID)
135+
gradientDrawableChecked.setStroke(borderWidth, colorID)
134136
}
135137

136138
private fun setTextStyle(textStyle: Typeface?) {
137139
lableTitle.typeface = textStyle
138140
editText.typeface = textStyle
139141
lableError.typeface = textStyle
140142
}
141-
}
143+
}

customedittextoutlinedborder/src/main/res/values/attrs.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<attr name="custom_component_editText_bg_color" format="color" />
1818
<attr name="custom_component_error_text_bg_color" format="color" />
1919
<attr name="custom_component_maxLength" format="integer"/>
20+
<attr name="custom_component_border_width" format="integer"/>
2021
</declare-styleable>
21-
</resources>
22+
</resources>

0 commit comments

Comments
 (0)