项目作者: a-tolstykh

项目描述 :
Android TextView with rich support of compound drawables
高级语言: Java
项目地址: git://github.com/a-tolstykh/textview-rich-drawable.git
创建时间: 2016-10-19T16:07:41Z
项目社区:https://github.com/a-tolstykh/textview-rich-drawable

开源协议:Apache License 2.0

下载


TextViewRichDrawable Android Arsenal

This is a tiny library which empowers TextView’s (and its inheritors) compound drawables with size specifying, vector support and tinting. Currently empowers next Android views with RichDrawable support:

  • Button -> ButtonRichDrawable
  • CheckBox -> CheckBoxRichDrawable
  • EditText -> EditTextRichDrawable
  • RadioButton -> RadioButtonRichDrawable
  • TextView -> TextViewRichDrawable

This library is just an extension of Android’s TextView.

Usage

  • Enable vector Drawable support for pre Lollipop devices (more details):
  1. android {
  2. defaultConfig {
  3. vectorDrawables.useSupportLibrary = true
  4. }
  5. }
  • In XML layout:
  1. <com.tolstykh.textviewrichdrawable.TextViewRichDrawable
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:text="Some text"
  5. app:compoundDrawableHeight="24dp"
  6. app:compoundDrawableWidth="24dp"
  7. app:drawableTopVector="@drawable/some_vector_drawble"
  8. app:drawableEndVector="@drawable/another_vector_drawable"
  9. app:drawableTint="@color/colorAccent" ></com.tolstykh.textviewrichdrawable.TextViewRichDrawable>
  • All customizable attributes:
  1. <declare-styleable name="TextViewRichDrawable">
  2. <attr name="compoundDrawableWidth" format="dimension"></attr>
  3. <attr name="compoundDrawableHeight" format="dimension"></attr>
  4. <attr name="drawableStartVector" format="reference" ></attr>
  5. <attr name="drawableTopVector" format="reference" ></attr>
  6. <attr name="drawableEndVector" format="reference" ></attr>
  7. <attr name="drawableBottomVector" format="reference" ></attr>
  8. <attr name="drawableTint" format="reference" ></attr>
  9. </declare-styleable>

Example

TextView-rich-drawable

Download

  1. repositories {
  2. jcenter()
  3. }
  1. compile 'com.tolstykh.textviewrichdrawable:textview-rich-drawable:0.3.2'

License

  1. Copyright 2016 Oleksandr Tolstykh
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.