样式百变的RTextView

作者: 5afd372c86ba | 来源:发表于2017-09-26 10:33 被阅读3次
名称 RTextView
语言 Android
平台 GitOSC
作者 Ruffian-痞子
链接 点此进入
备注 更多精彩开源库推荐请访问明灯小站

今天给大家推荐一款样式百变的TextView,该控件封装了多种样式,开发者可通过xml布局文件设置其属性来控制样式,省去写很多selector文件的烦恼。
效果图

1 1
使用方法
  1. 添加依赖
compile 'com.ruffian.library:RTextView:1.0.0'
  1. 添加到布局文件
<com.ruffian.library.RTextView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:gravity="center"
    android:text="文本控件"

    //背景颜色 对应三个状态
    rtv:background_normal="#3F51B5"
    rtv:background_pressed="#FF450F21"
    rtv:background_unable="#c3c3c3"

    //边框颜色 对应三个状态
    rtv:border_color_normal="#FF4081"
    rtv:border_color_pressed="#3F51B5"
    rtv:border_color_unable="#c3c3c3"

    //边框宽度 对应三个状态 一般设置相同值
    rtv:border_width_normal="3dp"
    rtv:border_width_pressed="4dp"
    rtv:border_width_unable="5dp"

    //虚线边框 1.虚线边框宽度 2.虚线间隔
    rtv:border_dash_width="10dp"
    rtv:border_dash_gap="4dp"

    //圆角度数 1.四周统一值 2.四个方向各个值
    //xml:  通过xml 设置了 corner_radius ,则 corner_radius_xxx 不起作用
    //java: 通过java代码设置 corner_radius_xxx ,则 corner_radius 不起作用
    rtv:corner_radius="10dp"
    rtv:corner_radius_top_left="10dp"
    rtv:corner_radius_bottom_left="15dp"
    rtv:corner_radius_bottom_right="20dp"
    rtv:corner_radius_top_right="25dp"

    //drawableXXX icon 对应三个状态
    rtv:icon_src_normal="@mipmap/icon_phone_normal"
    rtv:icon_src_pressed="@mipmap/icon_phone_pressed"
    rtv:icon_src_unable="@mipmap/icon_phone_unable"

    //drawableXXX icon 方向 {上,下,左,右}
    rtv:icon_direction="top"

    //drawableXXX icon 宽/高
    rtv:icon_height="30dp"
    rtv:icon_width="30dp"

    //文字颜色 对应三个状态
    rtv:text_color_normal="#c3c3c3"
    rtv:text_color_pressed="#3F51B5"
    rtv:text_color_unable="#FF4081"
    />

也可以通过Java代码设置样式

    RTextView textView=(RTextView) findViewById(R.id.text1);
    //set...
    textView.setIconNormal(getDrawable(R.mipmap.ic_launcher))
            .setIconHeight(10)
            .setIconWidth(20)
            .setIconDirection(RTextView.ICON_DIR_TOP);
    //get...
    int iconHeight=textView.getIconHeight();

更多使用方法,请参考其GitOSC Page

相关文章

  • 样式百变的RTextView

    今天给大家推荐一款样式百变的TextView,该控件封装了多种样式,开发者可通过xml布局文件设置其属性来控制样式...

  • RTextView 使用

    欢迎使用 RTextView 项目地址: RuffianZhong/RTextView 简介:基于 TextVie...

  • TextView背景圆角控件

    GitHub地址:https://github.com/RuffianZhong/RTextView 使用 1.添...

  • 10天word精进特训营之快速制作美观的文档

    梳理文档结构 划分段落 提取关键 突出要点 应用自带样式 运用标题、标题1、标题2的样式 百变文档主题 设计→选择...

  • 列表和表格

    1.列表的样式 在 中添加样式,整个列表样式改变。在 中只变一项。 list-style-type:dis...

  • 欧式装修材料教您墙纸挑选小妙招

    墙纸有着丰富的图案,多彩的花色,百变的样式,能够铺贴出更个性更时尚的墙面。那么,怎样挑选墙纸呢?接下来小编为大家介...

  • vue 小记

    占满单个页面的方法: index.html 里设置样式,在主app.vue设置宽高为百分百即可 引入样式重置样式 ...

  • angular 2 ngStyle的用法

    普通样式 [ngStyle]="{ 'height': item.height}" 百分比样式 [ngStyle]...

  • 百变网师的百变课堂

    问了自己内心很多次学习的意义是什么? 其实我觉得“越努力越幸运”。 有时候总感觉时间不够,...

  • JavaScript 基础

    内部样式 外部样式与 css 外部样式类似 三种提示框 一般用的很少,会卡住页面,一般放到尾部 变量 不用为每个变...

网友评论

    本文标题:样式百变的RTextView

    本文链接:https://www.haomeiwen.com/subject/chxsextx.html