项目作者: fajaragungpramana

项目描述 :
Library for android. FieldInput is layout component base on ViewGroup LinearLayout for get input from user.
高级语言: Kotlin
项目地址: git://github.com/fajaragungpramana/field-input.git
创建时间: 2021-01-24T10:45:19Z
项目社区:https://github.com/fajaragungpramana/field-input

开源协议:Apache License 2.0

下载


Android Field Input


License




Library for android. FieldInput is layout component base on ViewGroup LinearLayout for get input from user.

Installation

Add it in your root build.gradle at the end of repositories:

  1. allProjects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add the dependency:

  1. dependencies {
  2. implementation 'com.github.fajaragungpramana:field-input:0.0.4'
  3. }

Usage

Define a view in your layout file:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical">
  7. <com.github.fajaragungpramana.field.FieldInput
  8. android:id="@+id/field_input"
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:layout_marginHorizontal="16dp"
  12. android:layout_marginTop="16dp"
  13. app:drawableEnd="@drawable/ic_barcode"
  14. app:focusable="true"
  15. app:hint="@string/app_name"
  16. app:inputType="text"
  17. app:textAllCaps="false"
  18. app:textColor="@color/black"
  19. app:textSize="14sp" ></com.github.fajaragungpramana.field.FieldInput>
  20. </LinearLayout>

Handle drawable click listener.

  1. fieldInput.setOnClickDrawableListener(DrawablePosition.END) {
  2. Log.d(MainActivity::class.simpleName, "Drawable ${DrawablePosition.END} Clicked!")
  3. }

Get or do something when user is still typing text.

  1. fieldInput.setOnTextChanged { text ->
  2. // Do something hire when user still typing
  3. }

Set error message.

  1. fieldInput.errorMessage = "Type something error message here!"

Set or get text input.

  1. fieldInput.text // Do this to get input
  2. fieldInput.text = "Type something here!" // Do this to set input

Preview

Idle






















































Typing






















































Error






















































Documentation

Attribute for FieldInput
| Attribute Name | Default Value | Description |
|————————|———————-|——————-|
| hint | null | For set hint of field |
| focusable | true | For activate focus |
| style | null | For set text appearance of text field |
| textAllCaps | false | For activate field text caps |
| drawableEnd | null | For put drawable in the right side |
| inputType | text | For input type field |
| textColor | null | For set color text field |
| textSize | 14sp | For set text size field |

License

Copyright 2021 Fajar Agung Pramana

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

  1. 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.