Giter Site home page Giter Site logo

rohitpuriji / android-edit-textview-library Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 1.45 MB

A Library to manage properties of Edittext and Textview

Java 100.00%
android-library edittextview edittext edittextfont textview textviewfont validation-library fonttype textviewcompat

android-edit-textview-library's Introduction

EditTextviewLibrary

This Library can be used to create Textview and Edittext efficiently , this library provides you 16 type of font styles, different type of validation on fields, types of text sizes and some default view like text color,text size, font style, type face etc. you can also change that properties by using Library methods.

Only you have to add jitpack in your root build.gradle :

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

and add the dependency in app.gradle :

dependencies {  
        compile 'com.github.rohitpuriji:EditTextviewLibrary:-SNAPSHOT'
      }

This library made with java8 so add the jack option inside defaultCondig in your app gradle file :

    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    jackOptions {
        enabled true
    }

and add compile ad dex options :

  dexOptions {
    incremental true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

You can create field in layout file like this :

  <com.tech.edittextviewlibrary.TextViewField
      android:layout_width="match_parent"
      android:layout_margin="10dp"
      android:id="@+id/tvUsername"
      android:layout_height="wrap_content"/>


  <com.tech.edittextviewlibrary.EdittextField
      android:layout_width="match_parent"
      android:layout_margin="10dp"
      android:id="@+id/etFirstName"
      android:inputType="textPassword"
      android:layout_height="wrap_content"/>

  <com.tech.edittextviewlibrary.EdittextField
      android:layout_width="match_parent"
      android:layout_margin="10dp"
      android:id="@+id/etEmail"
      android:layout_height="wrap_content"/>


  <com.tech.edittextviewlibrary.EdittextField
      android:layout_width="match_parent"
      android:layout_margin="10dp"
      android:id="@+id/etUsername"
      android:inputType="textPassword"
      android:layout_height="wrap_content"/>

  <com.tech.edittextviewlibrary.EdittextField
      android:layout_width="match_parent"
      android:layout_margin="10dp"
      android:id="@+id/etPassword"
      android:inputType="textPassword"
      android:layout_height="wrap_content"/>

  <Button
      android:layout_width="wrap_content"
      android:text="Check"
      android:padding="10dp"
      android:id="@+id/btnCheck"
      android:layout_gravity="center"
      android:layout_height="wrap_content" />

Then access Fields like this :

      TextViewField tvUsername = (TextViewField) findViewById(R.id.tvUsername);
      final EdittextField etEmail = (EdittextField) findViewById(R.id.etEmail);
      final EdittextField etPassword = (EdittextField) findViewById(R.id.etPassword);
      EdittextField etFirstName = (EdittextField)findViewById(R.id.etFirstName);
      EdittextField etUsername = (EdittextField)findViewById(R.id.etUsername);

you can set text by using setTextString Method.

      tvUsername.setTextString("Registration form");  

you can set text color by using setTextStringcolor Method otherwise default color will be GRAY.

      tvUsername.setTextStringcolor(Color.BLUE);

you can set view background color by using setBgColor Method otherwise default color will be WHITE.

      tvUsername.setBgColor(Color.BLUE);

you can set padding by using setTextPadding Method otherwise default padding will be 20dp.

      etFirstName.setTextPadding(10,10,10,10);

We have basic 8 types of font style with regular and bold format like :

      *
      *    arial,
      *    courier,
      *    georgia,
      *    helvetica,
      *    roboto,
      *    tahoma,
      *    times,
      *    verdana
      *
      * 
      tvUsername.setTextTypeFaceBold(FontTypes.georgia,this);
      etFirstName.setTextTypeFaceNormal(FontTypes.georgia,this);

you can set text font size by using setFontSize Method

      there are many sizes available :
        *
        *      small(12),
        *      mid(15),
        *      large(17),
        *      xlarge(20),
        *      xxlarge(22);
        *
        *
      tvUsername.setFontSize(FontSizeTypes.xxlarge);

you can set some background view or drawable xml by using setBackgroundView Method otherwise a default drawable xml will be use.

      etEmail.setBackgroundView(R.drawable.edittext_bg);

Similarly you can set Edittext hint text,color.

We have basic 4 types of Field Validations like :

      *
      *       EmailType,
      *       PasswordType,
      *       OnlyAlphabetsType,
      *       AlphaNumericTypes,
      *       None
      *
      etEmail.setValidationType(ValidationType.EmailType,"Not a Valid email!");

you can set password length by using setValidationLength Method otherwise default length will be 6.

        etPassword.setValidationLength(PasswordLength.Five);

you can set error message by passing second parameter as a message if empty then default message will show.

          etPassword.setValidationType(ValidationType.PasswordType,"");

And on button click you can

Button btnCheck = (Button)findViewById(R.id.btnCheck);
        btnCheck.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

              //On submit you only need to check getError null if getError==null then field has valid entry.

              if (etEmail.getError() == null && !TextUtils.isEmpty(etEmail.getText().toString()){
                  Toast.makeText(MainActivity.this,"etUsername valid entry",Toast.LENGTH_LONG).show();
              }

              if (etPassword.getError() != null && !TextUtils.isEmpty(etPassword.getText().toString()){
                  Toast.makeText(MainActivity.this,"etPassword invalid entry",Toast.LENGTH_LONG).show();
              }

          }
      });

For more information please check the code.

Developed By

Rohit Puri

License

Copyright Rohit Puri Copyright (C) 2011 The Android Open Source Project

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.

android-edit-textview-library's People

Contributors

rohitpurievontech avatar rohitpuriji avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.