Git Product home page Git Product logo

drawabletextview's Introduction

DrawableTextView

自定义控件 :drawable 跟随TextView居中
The drawable follows the text centered

截图:

DrawableTextView

###Manually

你只需要这添加这两个文件就可以使用了!

  • deadline/DrawableTextView.java
  • res/values/attrs.xml

###代码中这样设置即可

drawable = ContextCompat.getDrawable(getContext(), R.mipmap.xxx);
setDrawable(DrawableTextView.LEFT, drawable, width, height);

Customizable attributes

xml中定义了以下属性

  • Define xmlns:app="http://schemas.android.com/apk/res-auto" on root of your xml file
<deadline.DrawableTextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            
            android:drawablePadding="5dp"
            
            app:bottomDrawable="@mipmap/camera"
            app:bottomDrawableHeight="20dp"
            app:bottomDrawableWidth="20dp"
            
            app:leftDrawable="@mipmap/camera"
            app:leftDrawableHeight="20dp"
            app:leftDrawableWidth="20dp"
            
            app:rightDrawable="@mipmap/camera"
            app:rightDrawableHeight="20dp"
            app:rightDrawableWidth="20dp"
            
            app:topDrawable="@mipmap/camera"
            app:topDrawableHeight="20dp"
            app:topDrawableWidth="20dp"/>

Developed By

deadline

Blog : http://www.jianshu.com/users/25e80ace21b8/latest_articles

drawabletextview's People

Contributors

niniloveyou avatar sloaix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drawabletextview's Issues

动态New的时候有点问题

DrawableTextView mDrawableTextView = new DrawableTextView(this);
mDrawableTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mDrawableTextView.setDrawable(DrawableTextView.RIGHT, ContextCompat.getDrawable(this, R.mipmap.ic_launcher), dip2px(this, 10), dip2px(this, 10));
mDrawableTextView.setText("帖子");
mContentView.addView(mDrawableTextView);

会出现显示不全。

建议

关于图片位置不能自定义,图片不能写选择器了.

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.