Compatible vector drawable(svg), flexible size setting and tinting color for compound drawables of TextView. Compound drawables支持vector drawable(svg)矢量图适配,灵活的尺寸设置以及着色等功能的TextView。
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app New features: Adjust width or height of text bounds or view bounds Dec 23, 2017
gradle/wrapper
screenshot
vectorcompattextview
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

API License

VectorCompatTextView

  • Compatible VectorDrawable(svg)
  • flexible size setting for CompoundDrawable
  • tint drawables with color
  • support StateListDrawable(mostly checked_state)

  • 适配VectorDrawable矢量图(svg)
  • 灵活地设置CompoundDrawable的尺寸大小
  • 为CompoundDrawable着色
  • 支持StateListDrawable(主要是checked_state)

Screenshot

demo5

Download

root project:build.gradle

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

app:build.gradle

  android {
      ...
      defaultConfig {
          ...
          vectorDrawables.useSupportLibrary = true  // necessarily
      }
  ...

  dependencies {
     // e.g. compile 'com.github.woxingxiao:VectorCompatTextView:2.3'
     compile 'com.github.woxingxiao:VectorCompatTextView:${LATEST_VERSION}'
  }

Usage

<com.xw.repo.VectorCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="GitHub"
    app:drawableLeftCompat="@drawable/svg_ic_github"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Next"
    app:drawableRightCompat="@drawable/svg_ic_arrow_right"
    app:tintDrawableInTextColor="true"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="ON"
    app:drawableCompatColor="#f44336"
    app:drawableBottomCompat="@drawable/svg_ic_line"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="GitHub"
    app:drawableAdjustTextWidth="true"
    app:drawableTopCompat="@drawable/svg_ic_github"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="GitHub"
    app:drawableWidth="24dp"
    app:drawableHeight="32dp"
    app:drawableLeftCompat="@mipmap/ic_launcher"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="评论"
    app:drawableAdjustTextHeight="true" <!-- text bounds -->
    app:drawableLeftCompat="@drawable/shape_rect_solid_red"
    app:drawableWidth="4dp"/>

<com.xw.repo.VectorCompatTextView
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:checked="true"
    android:gravity="center"
    android:text="SELECTED TAB"
    android:textColor="@drawable/selector_text_color_tab"
    app:drawableAdjustViewWidth="true" <!-- view bounds -->
    app:drawableBottomCompat="@drawable/selector_drawable_tab"
    app:drawableHeight="2dp"/>

Check the Demo for complete usage.

LICENSE

MIT