|
| 1 | +# CompoundIconTextView |
| 2 | + |
| 3 | +An android library that is able to set a vector drawable at text view pre-Lollipop. |
| 4 | + |
| 5 | +[](http://developer.android.com/index.html) |
| 6 | +[](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
| 7 | +[](http://www.apache.org/licenses/LICENSE-2.0) |
| 8 | +[](https://bintray.com/aakira/maven/compound-icon-textview/_latestVersion) |
| 9 | + |
| 10 | +## Preview |
| 11 | + |
| 12 | +![PREVIEW][preview] |
| 13 | + |
| 14 | +## Features |
| 15 | + |
| 16 | +* Set a vector drawable at text view pre-Lollipop |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### Code |
| 21 | + |
| 22 | +```Java |
| 23 | + |
| 24 | +CompoundIconTextView tv = (CompoundIconTextView) findViewById(R.id.compoundIconTextView); |
| 25 | + |
| 26 | +// set icon drawable |
| 27 | +tv.setVectorDrawableTop(R.drawable.ic_android_black_24dp); |
| 28 | +tv.setVectorDrawableLeft(R.drawable.ic_android_black_24dp); |
| 29 | + |
| 30 | +// set icon color |
| 31 | +tv.setIconColorResource(R.color.colorPrimary); |
| 32 | + |
| 33 | +// set icon size |
| 34 | +tv.setIconSizeResource(R.dimen.icon_size, R.dimen.icon_size); |
| 35 | +tv.setIconSize(32, 32); |
| 36 | + |
| 37 | +// clear icon |
| 38 | +tv.setVectorDrawableRight(CompoundIconTextView.UNDEFINED_RESOURCE); |
| 39 | + |
| 40 | +``` |
| 41 | + |
| 42 | +### Xml |
| 43 | + |
| 44 | +```xml |
| 45 | + |
| 46 | +<?xml version="1.0" encoding="UTF-8"?> |
| 47 | + <com.github.aakira.compoundicontextview.CompoundIconTextView |
| 48 | + android:id="@+id/compoundIconTextView" |
| 49 | + android:layout_width="wrap_content" |
| 50 | + android:layout_height="wrap_content" |
| 51 | + android:drawablePadding="4dp" |
| 52 | + android:gravity="center" |
| 53 | + android:text="Hello World!" |
| 54 | + android:textColor="#3F51B5" |
| 55 | + android:textSize="16sp" |
| 56 | + app:cit_drawableLeft="@drawable/ic_android_black_24dp" |
| 57 | + app:cit_iconColor="#000" |
| 58 | + app:cit_iconHeight="16dp" |
| 59 | + app:cit_iconWidth="16dp" /> |
| 60 | +``` |
| 61 | + |
| 62 | +### Attributes |
| 63 | + |
| 64 | +|attribute name|description| |
| 65 | +|:-:|:-:| |
| 66 | +|cit_drawableLeft|Sets a drawable or vector drawable to left of TextView| |
| 67 | +|cit_drawableTop|Sets a drawable or vector drawable to top of TextView| |
| 68 | +|cit_drawableBottom|Sets a drawable or vector drawable to bottom of TextView| |
| 69 | +|cit_drawableRight|Sets a drawable or vector drawable to right of TextView| |
| 70 | +|cit_iconWidth|Sets a width of icon| |
| 71 | +|cit_iconHeight|Sets a width of icon| |
| 72 | +|cit_iconColor|Sets a icon color| |
| 73 | + |
| 74 | +## Setup |
| 75 | + |
| 76 | +### Gradle |
| 77 | + |
| 78 | +Add the dependency in your `build.gradle` |
| 79 | + |
| 80 | +```groovy |
| 81 | +buildscript { |
| 82 | + repositories { |
| 83 | + jcenter() |
| 84 | + } |
| 85 | +} |
| 86 | +
|
| 87 | +dependencies { |
| 88 | + compile 'com.github.aakira:compound-text-view:1.0.0@aar' |
| 89 | +} |
| 90 | +``` |
| 91 | +## Using libraries |
| 92 | + |
| 93 | +* [Material icons](https://material.io/icons/#ic_cloud_download) |
| 94 | + |
| 95 | +## Author |
| 96 | + |
| 97 | +### Akira Aratani |
| 98 | + |
| 99 | +* Twitter |
| 100 | + - [@_a_akira](https://twitter.com/_a_akira) |
| 101 | +* Mail |
| 102 | + - developer.a.akira@gmail.com |
| 103 | + |
| 104 | +## License |
| 105 | + |
| 106 | +``` |
| 107 | +Copyright (C) 2017 A.Akira |
| 108 | +
|
| 109 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 110 | +you may not use this file except in compliance with the License. |
| 111 | +You may obtain a copy of the License at |
| 112 | +
|
| 113 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 114 | +
|
| 115 | +Unless required by applicable law or agreed to in writing, software |
| 116 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 117 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 118 | +See the License for the specific language governing permissions and |
| 119 | +limitations under the License. |
| 120 | +``` |
| 121 | + |
| 122 | +[preview]: /arts/preview.png |
0 commit comments