Coder Social home page Coder Social logo

materialinitials's Introduction

Material Initials

Download

An indicator that can be used as a background of person image or when it the is no image. Possibilities include every application that utilises human resources (numbers in contact apps, messages in chat applications, etc...)

Possibilities:

1. Initials made from one pair of String:

One pair

2. Initials made from two pairs of String:

Two pairs

3. Initials made from three pairs of String:

Three pairs

4. Initials made from four pairs of String:

Four pairs

5. Three letter initials:

Three letter pairs

6. Customisable alpha of letters:

Customisable alpha

7. Black tinted letters:

Black tinted letters

8. Rotated letters:

Rotated letters

Usage:

Import gradle dependency:

  • Add following lines to you project's main build.gradle:

    buildscript {
        repositories {
            jcenter()
        }
    }
    
  • Add a dependency to application build.gradle:

    compile 'com.rzagorski:materialinitials:0.8.0'
    

Add MaterialInitials view in your .xml

<com.rzagorski.materialinitials.MaterialInitials
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

or use MaterialInitialsDrawable dynamically in your code:

MaterialInitialsDrawable drawable = new MaterialInitialsDrawable();
image.setImageDrawable(drawable);

Conifguration

There are three possible ways to control each aspect of drawing:

1. Use attributes in .xml layout

2. Use methods of MaterialInitials to control view

3. Use method of MaterialInitialsDrawable to control Drawable directly.

Options:

1. Initials
Initials are composed of beginning letters of words passed to it. Each String must contain at least one word and at most 3 words.

Layout View Drawable
`com.rzagorski.materialinitials.MaterialInitials`
  `app:mi_texts="@array/string_array"/>`
`String[] values;`
`miView.setTexts(values);`
`String[] values`
`miDrawable.setTexts(values);`

2. Background colors
Background colors must be the same size as texts size. The first initials will be drawn with first color background. The second initials will be drawn with second color background, etc.
If colors are not set, the background color is taken randomly from the set of 500 material colors

Layout View Drawable
`com.rzagorski.materialinitials.MaterialInitials`
  `app:mi_background_colors="@array/color_array"/>`
`int[] colors;`
`miView.setBackgroundColors(colors);`
`int[] colors;`
`miDrawable.setBackgroundColors(colors);`

3. Text color
This parameter specifies the rgb channels of a color used to draw initials. Must be between 0 and 255.

Layout View Drawable
`com.rzagorski.materialinitials.MaterialInitials`
  `app:mi_text_color="@color/color"/>`
`int color;`
`miView.setTextColor(color);`
`int color;`
`miDrawable.setTextColor(color);`

4. Text alpha
This parameter specifies the alpha channel of a color used to draw initials. Must be between 0 and 255.

Layout View Drawable
`com.rzagorski.materialinitials.MaterialInitials`
  `app:mi_textAlpha="@integer/alpha"/>`
`int alpha;`
`miView.setTextAlpha(alpha);`
`int alpha;`
`miDrawable.setTextAlpha(alpha);`

5. Text rotation
This parameter specifies the rotation of initials in clockwise direction. Must be between 0 and 360 modulo.

Layout View Drawable
`com.rzagorski.materialinitials.MaterialInitials`
  `app:mi_rotation="@integer/rotation/>"`
`int rotation;`
`miView.setTextRotation(rotation);`
`int rotation;`
`miDrawable.setTextRotation(rotation);`

License

Copyright 2016 Robert Zagórski.

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.

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.