Material Design Hub

Friday, December 5, 2014

Android TextDrawable

11:36 AM

Android TextDrawable

Android TextDrawable

Android TextDrawable
watch the demo

Description:-
This light-weight library provides images with letter/text like the Gmail app. It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.

Download TextDrawable library and sample code


How To Use:-

Step 1: Create a new Android Project

Step 2: Import TextDrawable Library to your Android Application Project 
     1: File->New->Other
     2: Select Android Project
     3: Select "Create Project from existing source"
     4: Click "Browse..." 
     5: Finish (Now action bar project in your workspace)
     6: Right-click on your project -> Properties
     7: In Android->Library section click Add
     8: select recently added project -> Ok
     9: that's it!

Step 3: Use TextDrawable Library.
<ImageView android:layout_width="60dp"
           android:layout_height="60dp"
           android:id="@+id/image_view"/>
Create simple tile:
TextDrawable drawable = TextDrawable.builder()
                .buildRect("A", Color.RED);

ImageView image = (ImageView) findViewById(R.id.image_view);
image.setImageDrawable(drawable);
Create rounded corner or circular tiles:
TextDrawable drawable1 = TextDrawable.builder()
                .buildRoundRect("A", Color.RED, 10); // radius in px

TextDrawable drawable2 = TextDrawable.builder()
                .buildRound("A", Color.RED);
Add border:
TextDrawable drawable = TextDrawable.builder()
                .beginConfig()
                    .withBorder(4) /* thickness in px */
                .endConfig()
                .buildRoundRect("A", Color.RED, 10);
Modify font style:
TextDrawable drawable = TextDrawable.builder()
                .beginConfig()
                    .textColor(Color.BLACK)
                    .useFont(Typeface.DEFAULT)
                    .fontSize(30) /* size in px */
                    .bold()
                    .toUpperCase()
                .endConfig()
                .buildRect("a", Color.RED)



Please Join our Facebook  Group and Page


Facebook group: Android controls

Facebook page: Android Controls


SUBSCRIBE TO OUR EMAIL NEWSLETTER & RECEIVE UPDATES RIGHT IN YOUR INBOX.   Click here


If You Have Any question or Suggestions Please Feel Free to Comments .

0 comments