Lined Edit Text

illustrations illustrations illustrations illustrations illustrations illustrations illustrations

Lined Edit Text

GitHub


Published on May 17, 2020 by Man Ho on Android Development

An edit text allows creating many styles of edit text with lines.

Table of contents

Gradle

Step 1. Add this in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://www.jitpack.io' }
    }
}

Step 2. Add dependency

dependencies {
    ...
    implementation 'com.github.homanad:LinedEditText:1.0.0'
}

Usage

This is done simply by add this View into your layout:

<com.homanad.android.widget.LinedEditText
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Attributes

For ease of use, you can also set all values in the corresponding code as follows:

AttributeXMLDescriptionTypeDefault value
dashWidthlet_dashWidthThe length of each dash when using the line with dashed linesDimension2dp
dashGaplet_dashGapThe distance of each dash when you want to use the line with solid linesDimension2dp
lineWidthlet_lineWidthThe width of the line, in the x-directionDimension1dp
lineColorlet_lineColorLine colorColor resourceBlack
isShowLineslet_showLinesOption for showing or hiding linesBooleantrue
lineStylelet_lineStyleDetermines the style of the line: stroke, dashes, or dotsEnumstroke
dotSpacelet_dotSpaceFor dot style, this attribute is used to define the spacing between dotsDimension3dp
lineSpacingExtralet_lineSpacingExtraThe distance of the line from the footerDimension1dp

Here, notice the values written with “.dp” extension

Because these attributes are dimension values, so for an Int or Float value become a dp value, I’ve provided two extension functions to convert the Int or Float type to dp, you just need to call it as an extension function.

License

Copyright 2021 Man Ho

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.