Code Monkey home page Code Monkey logo

vectorcompattextview's Introduction

API License

VectorCompatTextView

With this multifunctional TextView, the VectorDrawable resources can be set as CompoundDrawables, furthermore, the majority of scenarios to manipulate CompoundDrawables have been supported, such as checked state, color tinting/setting, custom size setting, visibility, RTL, etc. AndroidX version is available.

这个炒鸡强大的库可以让你轻松将VectorDrawable资源设置为CompoundDrawable,并且支持大多数操控CompoundDrawable的情景,如:checked状态,颜色设置或着色,自定义宽高,隐藏或显示,RTL布局等等(当然常规资源如png/jpg,Drawable的子类等更不在话下)。有AndroidX版本。

Screenshot

demo5 demo6

Download

root project:build.gradle

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

app:build.gradle

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

  dependencies {
     // Support
     // e.g. implementation 'com.github.woxingxiao:VectorCompatTextView:2.7'
     implementation 'com.github.woxingxiao:VectorCompatTextView:${LATEST_VERSION}'

     // AndroidX
     // e.g. implementation 'com.github.woxingxiao:VectorCompatTextView:2.7-androidx'
     implementation 'com.github.woxingxiao:VectorCompatTextView:${LATEST_VERSION}-androidx'
  }

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

vectorcompattextview's People

Contributors

woxingxiao avatar

Watchers

James Cloos avatar

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.