java xml textview居中,开源 TextView Drawable跟随文字居中
DrawableTextView自定义控件 :drawable 跟随TextView居中The drawable follows the text centered截图:Manually你只需要这添加这两个文件就可以使用了!+ deadline/DrawableTextView.java+ res/values/attrs.xml代码设置drawable = ContextCompat.getDr
DrawableTextView
自定义控件 :drawable 跟随TextView居中
The drawable follows the text centered
截图:

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
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
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)