提供了一些工具类以及自定义 View,用于日常的 Android 快速开发

Androids

项目地址:1993hzw/Androids 

简介:提供了一些工具类以及自定义 View,用于日常的 Android 快速开发。something about android

更多:作者   提 Bug   

标签:

 

Androids 是本人根据平时的项目实践经验,为了提高 Android 开发效率而写的一个工具 SDK;里面提供了一些工具类以及自定义 View,可在实际项目开发时直接使用。

ANDROIDS

使用

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

dependencies {
    compile 'com.github.1993hzw:Androids:1.2.3'
}

项目结构

--AndroidsDemo 使用例子

--androids 库工程

自定义 View

  • STextView/SLayout

    可直接在布局文件设置 shape 和 selector,实现点击效果

    点击查看示例代码

    STextView 支持的属性

    <attr name="stv_text_color_selected" format="color"/>
    <attr name="stv_text_color_pressed" format="color"/>
    <attr name="stv_text_color_disable" format="color"/>
    

    STextView/SLayout 支持的属性

    <!-- 背景状态 -->
    <attr name="sel_background_pressed" format="reference|color"/>
    <attr name="sel_background_selected" format="reference|color"/>
    
    <!-- 背景形状 -->
    <attr name="sel_background_shape" format="enum">
      <enum name="rect" value="0"/>
      <enum name="oval" value="1"/>
      <enum name="line" value="2"/>
      <enum name="ring" value="3"/>
    </attr>
    <!-- 背景圆角 -->
    <attr name="sel_background_corners" format="dimension"/>
    <attr name="sel_background_corner_topLeft" format="dimension"/>
    <attr name="sel_background_corner_topRight" format="dimension"/>
    <attr name="sel_background_corner_bottomLeft" format="dimension"/>
    <attr name="sel_background_corner_bottomRight" format="dimension"/>
    
    <!-- 背景边框默认状态 -->
    <attr name="sel_background_border_color" format="color"/>
    <attr name="sel_background_border_width" format="dimension"/>
    <!-- 背景边框状态 -->
    <attr name="sel_background_border_pressed" format="color"/>
    <attr name="sel_background_border_selected" format="color"/>
    
    <!-- ripple 水波纹效果-->
    <attr name="sel_background_ripple" format="reference|color"/>
    <attr name="sel_background_ripple_mask" format="reference|color"/>
    <!-- ripple mask 形状(仅在 sel_background_ripple_mask 为 color 时生效)-->
    <attr name="sel_background_ripple_mask_shape" format="enum">
      <enum name="rect" value="0"/>
      <enum name="oval" value="1"/>
      <enum name="line" value="2"/>
      <enum name="ring" value="3"/>
    </attr>
    <!-- ripple mask 圆角 -->
    <attr name="sel_background_ripple_mask_corners" format="dimension"/>
    <attr name="sel_background_ripple_mask_corner_topLeft" format="dimension"/>
    <attr name="sel_background_ripple_mask_corner_topRight" format="dimension"/>
    <attr name="sel_background_ripple_mask_corner_bottomLeft" format="dimension"/>
    <attr name="sel_background_ripple_mask_corner_bottomRight" format="dimension"/>
    
  • ShapeImageView

    可设置形状(圆形、圆角矩形)的 ImageView

    点击查看示例代码

    <attr name="siv_shape" format="enum">
      <enum name="rect" value="1"/>
      <enum name="circle" value="2"/>
      <enum name="oval" value="3"/>
    </attr>
    <attr name="siv_round_radius" format="dimension"/>
    <attr name="siv_round_radius_leftTop" format="dimension"/>
    <attr name="siv_round_radius_leftBottom" format="dimension"/>
    <attr name="siv_round_radius_rightTop" format="dimension"/>
    <attr name="siv_round_radius_rightBottom" format="dimension"/>
    <attr name="siv_border_size" format="dimension"/>
    <attr name="siv_border_color" format="color"/>
    

    《Android 自定义 View——可设置形状(圆形、圆角矩形、椭圆)的 ImageView,抗锯齿》

  • MaskImageView

    可在背景图和前景图显示遮罩效果的 ImageView

    点击查看示例代码

    <!-- 遮罩的层面:背景\前景图-->
    <attr name="miv_mask_level" format="enum">
      <enum name="background" value="1"/>
      <enum name="foreground" value="2"/>
    </attr>
    <!-- 设置了 setClickable(true)才生效,默认开启遮罩-->
    <attr name="miv_is_show_mask_on_click" format="boolean"/>
    <attr name="miv_mask_color" format="color"/>
    <!--是否忽略图片的透明度,默认为 true,透明部分不显示遮罩 -->
    <attr name="miv_is_ignore_alpha" format="boolean"/>
    

    《Android 自定义 View——可在背景图和前景图显示遮罩效果的 ImageView》

  • RatioImageView

    可以设置宽高比例的 ImageView

    点击查看示例代码

    <!-- 宽度是否根据 src 图片的比例来测量(高度已知) -->
    <attr name="riv_is_width_fix_drawable_size_ratio" format="boolean"/>
    <!-- 高度是否根据 src 图片的比例来测量(宽度已知) -->
    <attr name="riv_is_height_fix_drawable_size_ratio" format="boolean"/>
    <!--当 mIsWidthFitDrawableSizeRatio 生效时,最大宽度-->
    <attr name="riv_max_width_when_width_fix_drawable" format="dimension"/>
    <!--当 mIsHeightFitDrawableSizeRatio 生效时-->
    <attr name="riv_max_height_when_height_fix_drawable" format="dimension"/>
    <!-- 高度设置,参考宽度,如 0.5 , 表示 高度=宽度×0.5 -->
    <attr name="riv_height_to_width_ratio" format="float"/>
    <!-- 宽度设置,参考高度,如 0.5 , 表示 宽度=高度×0.5 -->
    <attr name="riv_width_to_height_ratio" format="float"/>
    <!--宽度和高度,避免 layout_width/layout_height 会在超过屏幕尺寸时特殊处理的情况-->
    <attr name="riv_width" format="dimension"/>
    <attr name="riv_height" format="dimension"/>
    

    《Android 自定 View——可以设置宽高比例的 ImageView》

  • ScrollPickerView

    滚动选择器,支持循环滚动,可实现生日选择器,老虎机等

   <!--滚动选择器通用属性-->
    <declare-styleable name="ScrollPickerView">
        <!-- 中间 item 的背景-->
        <attr name="spv_center_item_background" format="reference|color"/>
        <!-- 可见的 item 数量,默认为 3 个-->
        <attr name="spv_visible_item_count" format="integer"/>
        <!-- 中间 item 的位置,默认为 mVisibleItemCount / 2-->
        <attr name="spv_center_item_position" format="integer"/>
        <!-- 是否循环滚动,默认为 true,开启-->
        <attr name="spv_is_circulation" format="boolean"/>
        <!-- 不允许父组件拦截触摸事件,设置为 true 为不允许拦截,此时该设置才生效 -->
        <attr name="spv_disallow_intercept_touch" format="boolean"/>
        <!-- 滚动的方向-->
        <attr name="spv_orientation" format="string">
            <enum name="horizontal" value="1"/>
            <enum name="vertical" value="2"/>
        </attr>
    </declare-styleable>

    <!--文字选择器-->
    <declare-styleable name="StringScrollPicker">
        <!--文字渐变大小-->
        <attr name="spv_min_text_size" format="dimension"/>
        <attr name="spv_max_text_size" format="dimension"/>
        <!--文字渐变颜色-->
        <attr name="spv_start_color" format="color"/>
        <attr name="spv_end_color" format="color"/>
        <!--文字最大行宽-->
        <attr name="spv_max_line_width" format="dimension"/>
        <!--文字对齐方式-->
        <attr name="spv_alignment" format="enum">
            <enum name="center" value="1"/>
            <enum name="left" value="2"/>
            <enum name="right" value="3"/>
        </attr>
    </declare-styleable>

    <!--图片选择器-->
    <declare-styleable name="BitmapScrollPicker">
        <!-- 绘制图片的方式-->
        <attr name="spv_draw_bitmap_mode" format="string">
            <enum name="fill" value="1"/>
            <enum name="center" value="2"/>
            <enum name="size" value="3"/>
        </attr>
        <!-- 绘制图片的方式为 size 时,指定的图片绘制大小-->
        <attr name="spv_draw_bitmap_width" format="dimension"/>
        <attr name="spv_draw_bitmap_height" format="dimension"/>
        <!-- item 内容缩放倍数-->
        <attr name="spv_min_scale" format="float"/>
        <attr name="spv_max_scale" format="float"/>
    </declare-styleable>

点击查看示例代码

《 Android 自定义 view——滚动选择器》

《 android 图片滚动选择器的实现》

《 Android 滚动选择器——水平滚动》

工具类

更新

  • v1.2.3(17)

1.fix:SelectorAttrs 在低版本上没有设置背景色时显示黑色

  • v1.2.2(16)

1.优化手势识别类 TouchGestureDetector,ScaleGestureDetector 使用 Api27 源码

  • v1.2(14)

1.新增 EasyAdapter,用于 RecyclerView 的适配器,可支持设置点击、单选和多选模式。(Kotlin 版实现 )

2.修复 SLayout 没有设置背景色时导致 border 异常的问题

  • v1.1.8.1(13)

1.修复某些情况下滚动选择器不回调监听器的问题

  • v1.1.8(12)

1.SLayout 支持水波纹效果

2.兼容旧版本的 sel_background 属性

  • v1.1.7.1(11)

1.修复 SelectorAttrs 中 background_border 的 bug。

  • v1.1.7(10)

1.完善 SelectorAttrs 逻辑,支持设置图片。

2.增加 TouchGestureDetector

  • v1.1.6(9)

文字滚动选择器支持文字换行.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值