a super textview for android

Overview

SuperTextView

API Android Arsenal

重磅推出SuperTextView2.x版本,属性参数相比1.x有些变化,1.x的用户升级2.x的时候请注意

1、功能描述

SuperTextView是一个功能强大的View,可以满足日常大部分布局样式,开发者可已自行组合属性配置出属于自己风格的样式!可能描述起来没有概念,还是直接看效果图吧!

SuperButton拥有shape文件的大部分属性,从此写shape属性变得非常简单

CommonTextView只是SuperTextView的逻辑简化,其实功能并不差少哦,有兴趣的可以看看

如果觉得对你有用的话,点一下右上的星星赞一下吧!

2、 效果 Demo下载地址

3、如何使用

3.1、Android Studio导入方法,添加Gradle依赖

   先在项目根目录的 build.gradle 的 repositories 添加:

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

然后在dependencies添加:

        dependencies {
        ...
        compile 'com.github.lygttpod:SuperTextView:VERSION_CODE'
        }

温馨提示:项目中部分代码使用kotlin写的,所以你的项目需要支持kotlin

注意:VERSION_CODE为后面的数字,即最新的release版本号

3.2、项目中如何使用

3.2.1、布局中如何使用(示例中只列出部分属性,开发者可根据具体需求使用其他属性)

            <com.allen.library.SuperTextView
                android:layout_width="match_parent"
                android:layout_height="80dp"
                stv:sCenterBottomTextColor="@color/colorAccent"
                stv:sCenterBottomTextString="限额说明>>"
                stv:sCenterTopTextString=" "
                stv:sCenterViewGravity="left_center"
                stv:sLeftBottomTextString="招商银行(8888)"
                stv:sLeftIconRes="@drawable/bank_zhao_shang"
                stv:sLeftTopTextString="银行卡支付"
                stv:sLeftViewGravity="left_center"
                stv:sRightCheckBoxRes="@drawable/circular_check_bg"
                stv:sRightViewType="checkbox" />
        注意:
                1、上下的线可以通过   sDividerLineType 设置  有四种显示方式 none,top,bottom,both
                2、通过设置 sUseRipple=true 开启水波效果

3.2.2、代码中如何使用

       /**
     * 可以通过链式设置大部分常用的属性值
     */
   superTextView.setLeftTopString("")
                .setLeftString("")
                .setLeftBottomString("")
                .setCenterTopString("")
                .setCenterString("")
                .setCenterBottomString("")
                .setRightTopString("")
                .setRightString("")
                .setRightBottomString("")
                .setLeftIcon(0)
                .setRightIcon(0)
                .setCbChecked(true)
                .setCbBackground(null)
                .setLeftTvDrawableLeft(null)
                .setLeftTvDrawableRight(null)
                .setCenterTvDrawableLeft(null)
                .setCenterTvDrawableRight(null)
                .setRightTvDrawableLeft(null)
                .setRightTvDrawableRight(null);
                
   superTextView.setShapeCornersRadius(20)
                .setShapeCornersTopLeftRadius(20)
                .setShapeCornersBottomLeftRadius(20)
                .setShapeCornersTopRightRadius(20)
                .setShapeCornersBottomRightRadius(20)
                .setShapeStrokeColor(getResources().getColor(R.color.colorPrimary))
                .setShapeStrokeWidth(1)
                .setShapeSrokeDashWidth(1)
                .setShapeStrokeDashGap(5)
                .setShapeSolidColor(getResources().getColor(R.color.white))
                .setShapeSelectorNormalColor(getResources().getColor(R.color.red_btn))
                .setShapeSelectorPressedColor(getResources().getColor(R.color.gray))
                .useShape();//设置完各个参数之后这句调用才生效

3.2.3点击事件(可根据需求选择实现单个或者多个点击事件)

        /**
         * 根据实际需求对需要的View设置点击事件
         */
        /**
         * 根据实际需求对需要的View设置点击事件
         */
        superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClickListener(SuperTextView superTextView) {
                string = "整个item的点击事件";
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setLeftTopTvClickListener(new SuperTextView.OnLeftTopTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getLeftTopString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setLeftTvClickListener(new SuperTextView.OnLeftTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getLeftString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setLeftBottomTvClickListener(new SuperTextView.OnLeftBottomTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getLeftBottomString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setCenterTopTvClickListener(new SuperTextView.OnCenterTopTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getCenterTopString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setCenterTvClickListener(new SuperTextView.OnCenterTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getCenterString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setCenterBottomTvClickListener(new SuperTextView.OnCenterBottomTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getCenterBottomString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setRightTopTvClickListener(new SuperTextView.OnRightTopTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getRightTopString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setRightTvClickListener(new SuperTextView.OnRightTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getRightString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setRightBottomTvClickListener(new SuperTextView.OnRightBottomTvClickListener() {
            @Override
            public void onClickListener() {
                string = superTextView.getRightBottomString();
                Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
            }
        }).setLeftImageViewClickListener(new SuperTextView.OnLeftImageViewClickListener() {
            @Override
            public void onClickListener(ImageView imageView) {
                Toast.makeText(ClickActivity.this, "左边图片", Toast.LENGTH_SHORT).show();
            }
        }).setRightImageViewClickListener(new SuperTextView.OnRightImageViewClickListener() {
            @Override
            public void onClickListener(ImageView imageView) {
                Toast.makeText(ClickActivity.this, "右边图片", Toast.LENGTH_SHORT).show();
            }
        });

        superTextView_cb.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClickListener(SuperTextView superTextView) {
                superTextView.setCbChecked(!superTextView.getCbisChecked());
            }
        }).setCheckBoxCheckedChangeListener(new SuperTextView.OnCheckBoxCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                Toast.makeText(ClickActivity.this, "" + isChecked, Toast.LENGTH_SHORT).show();
            }
        });

        superTextView_switch.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClickListener(SuperTextView superTextView) {
                superTextView.setSwitchIsChecked(!superTextView.getSwitchIsChecked());
            }
        }).setSwitchCheckedChangeListener(new SuperTextView.OnSwitchCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                Toast.makeText(ClickActivity.this, "" + isChecked, Toast.LENGTH_SHORT).show();
            }
        });

3.2.4使用第三方库(Picasso或者Glide)加载网络图片

        String url1 = "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3860616424,1789830124&fm=80&w=179&h=119&img.PNG";
        String url2 = "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=219781665,3032880226&fm=80&w=179&h=119&img.JPEG";
        String url3 = "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3860616424,1789830124&fm=80&w=179&h=119&img.PNG";
        
        Picasso.with(this)
                .load(url1)
                .placeholder(R.drawable.head_default)
                .into(superTextView.getLeftIconIV());
        Glide.with(this)
                .load(url2)
                .placeholder(R.drawable.head_default)
                .fitCenter()
                .into(superTextView2.getRightIconIV());

        Glide.with(this)
                .load(url3)
                .placeholder(R.drawable.head_default)
                .into(new SimpleTarget<GlideDrawable>() {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                        superTextView3.setRightTvDrawableRight(resource);
                    }
                });

3.2.5、属性说明(以下属性全部可以通过xml文件配置和代码进行设置)

属性名 字段 描述 默认值
sLeftTextString string 左边文字字符串
sLeftTopTextString string 左上文字字符串
sLeftBottomTextString string 左下文字字符串
sCenterTextString string 中间文字字符串
sCenterTopTextString string 中上文字字符串
sCenterBottomTextString string 中下文字字符串
sRightTextString string 右边文字字符串
sRightTopTextString string 右上文字字符串
sRightBottomTextString string 右下文字字符串
sLeftTextColor color 左边文字颜色 默认0xFF373737
sLeftTopTextColor color 左上文字颜色 默认0xFF373737
sLeftBottomTextColor color 左下文字颜色 默认0xFF373737
sCenterTextColor color 中间文字颜色 默认0xFF373737
sCenterTopTextColor color 中上文字颜色 默认0xFF373737
sCenterBottomTextColor color 中下文字颜色 默认0xFF373737
sRightTextColor color 左边文字颜色 默认0xFF373737
sRightTopTextColor color 右上文字颜色 默认0xFF373737
sRightBottomTextColor color 右下文字颜色 默认0xFF373737
sLeftTextSize dimension 左边字体大小 默认15sp
sLeftTopTextSize dimension 左上字体大小 默认15sp
sLeftBottomTextSize dimension 左下字体大小 默认15sp
sCenterTextSize dimension 中间字体大小 默认15sp
sCenterTopTextSize dimension 中上字体大小 默认15sp
sCenterBottomTextSize dimension 中下字体大小 默认15sp
sRightTextSize dimension 右边字体大小 默认15sp
sRightTopTextSize dimension 右上字体大小 默认15sp
sRightBottomTextSize dimension 右下字体大小 默认15sp
sLeftLines integer 左边文字显示行数 默认不设置
sLeftTopLines integer 左上文字显示行数 默认不设置
sLeftBottomLines integer 左下文字显示行数 默认不设置
sCenterLines integer 中间文字显示行数 默认不设置
sCenterTopLines integer 中上文字显示行数 默认不设置
sCenterBottomLines integer 中下文字显示行数 默认不设置
sRightLines integer 右边文字显示行数 默认不设置
sRightTopLines integer 右上文字显示行数 默认不设置
sRightBottomLines integer 右下文字显示行数 默认不设置
sLeftMaxEms integer 左边文字显示个数 默认不设置
sLeftTopMaxEms integer 左上文字显示个数 默认不设置
sLeftBottomMaxEms integer 左下文字显示个数 默认不设置
sCenterMaxEms integer 中间文字显示个数 默认不设置
sCenterTopMaxEms integer 中上文字显示个数 默认不设置
sCenterBottomMaxEms integer 中下文字显示个数 默认不设置
sRightMaxEms integer 右边文字显示个数 默认不设置
sRightTopMaxEms integer 右上文字显示个数 默认不设置
sRightBottomMaxEms integer 右下文字显示个数 默认不设置
sLeftViewGravity enum 左边文字对齐方式
left_center(左对齐)
center(居中)
right_center(右对齐)
默认center
sCenterViewGravity enum 中间文字对齐方式
left_center(左对齐)
center(居中)
right_center(右对齐)
默认center
sRightViewGravity enum 右边文字对齐方式
left_center(左对齐)
center(居中)
right_center(右对齐)
默认center
sLeftTvDrawableLeft reference 左边TextView左侧的drawable
sLeftTvDrawableRight reference 左边TextView右侧的drawable
sCenterTvDrawableLeft reference 中间TextView左侧的drawable
sCenterTvDrawableRight reference 中间TextView右侧的drawable
sRightTvDrawableLeft reference 右边TextView左侧的drawable
sRightTvDrawableRight reference 右边TextView右侧的drawable
sLeftTvDrawableWidth dimension 左边TextView的drawable的宽度
sLeftTvDrawableHeight dimension 左边TextView的drawable的高度
sCenterTvDrawableWidth dimension 中间TextView的drawable的宽度
sCenterTvDrawableHeight dimension 中间TextView的drawable的高度
sRightTvDrawableWidth dimension 右边TextView的drawable的宽度
sRightTvDrawableHeight dimension 右边TextView的drawable的高度
sTextViewDrawablePadding dimension TextView的drawable对应的Padding 默认10dp
sLeftViewWidth dimension 左边textView的宽度 为了中间文字左对齐的时候使用
sTopDividerLineMarginLR dimension 上边分割线的MarginLeft和MarginRight 默认0dp
sTopDividerLineMarginLeft dimension 上边分割线的MarginLeft 默认0dp
sTopDividerLineMarginRight dimension 上边分割线的MarginRight 默认0dp
sBottomDividerLineMarginLR dimension 下边分割线的MarginLeft和MarginRigh 默认0dp
sBottomDividerLineMarginLeft dimension 下边分割线的MarginLeft 默认0dp
sBottomDividerLineMarginRight dimension 下边分割线的MarginRight 默认0dp
sDividerLineColor color 分割线的颜色 默认0xFFE8E8E8
sDividerLineHeight dimension 分割线的高度 默认0.5dp
sDividerLineType enum 分割线显示方式
none(不显示分割线)
top(显示上边的分割线)
bottom(显示下边的分割线)
both(显示上下两条分割线)
默认bottom
sLeftViewMarginLeft dimension 左边view的MarginLeft 默认10dp
sLeftViewMarginRight dimension 左边view的MarginRight 默认10dp
sCenterViewMarginLeft dimension 中间view的MarginLeft 默认10dp
sCenterViewMarginRight dimension 中间view的MarginRight 默认10dp
sRightViewMarginLeft dimension 右边view的MarginLeft 默认10dp
sRightViewMarginRight dimension 右边view的MarginRight 默认10dp
sLeftTextIsBold boolean 左边文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sLeftTopTextIsBold boolean 左上文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sLeftBottomTextIsBold boolean 左下文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sCenterTextIsBold boolean 中间文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sCenterTopTextIsBold boolean 中上文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sCenterBottomTextIsBold boolean 中下文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sRightTextIsBold boolean 右边文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sRightTopTextIsBold boolean 右上文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sRightBottomTextIsBold boolean 右下文字是否加粗 默认false(暂时去除此属性改为代码动态配置)
sLeftIconRes reference 左边图片资源 可以用来显示网络图片或者本地
sRightIconRes reference 右边图片资源 可以用来显示网络图片或者本地
sLeftIconWidth dimension 左边图片资源的宽度 用于固定图片大小的时候使用
sLeftIconHeight dimension 左边图片资源的高度 用于固定图片大小的时候使用
sRightIconWidth dimension 右边图片资源的宽度 用于固定图片大小的时候使用
sRightIconHeight dimension 右边图片资源的高度 用于固定图片大小的时候使用
sLeftIconMarginLeft dimension 左边图片资源的MarginLeft 默认10dp
sRightIconMarginRight dimension 右边图片资源的MarginLeft 默认10dp
sCenterSpaceHeight dimension 上中下三行文字的间距 默认5dp
sRightCheckBoxRes reference 右边CheckBox的资源
sRightCheckBoxMarginRight dimension 右边CheckBox的MarginRight 默认10dp
sIsChecked boolean 右边CheckBox是否选中 默认 false
sUseRipple boolean 是否开启点击出现水波效果 默认 true
sBackgroundDrawableRes reference SuperTextView的背景资源
sRightViewType enum 右边显示的特殊View
checkbox
switchBtn
默认都不显示
sRightSwitchMarginRight dimension 右边SwitchBtn的MarginRight 默认10dp
sSwitchIsChecked boolean 右边SwitchBtn是否选中 默认 false
sTextOff string TextOff 默认""
sTextOn string TextOn 默认""
sSwitchMinWidth dimension SwitchMinWidth 系统默认
sSwitchPadding dimension SwitchPadding 系统默认
sThumbTextPadding dimension ThumbTextPadding 系统默认
sThumbResource reference 右边SwitchBtn自定义选中资源 系统默认
sTrackResource reference 右边SwitchBtn自定义未选中资源 系统默认
sUseShape boolean 是否使用shape设置圆角及触摸反馈
设为true之后才能使用一下属性
默认false
sShapeSolidColor color 填充色 默认false
sShapeSelectorPressedColor color 按下时候的颜色 默认0xffffffff
sShapeSelectorNormalColor color 正常显示的颜色 默认0xffffffff
sShapeCornersRadius dimension 四个角的圆角半径 默认0dp
sShapeCornersTopLeftRadius dimension 左上角的圆角半径 默认0dp
sShapeCornersTopRightRadius dimension 右上角的圆角半径 默认0dp
sShapeCornersBottomLeftRadius dimension 左下角的圆角半径 默认0dp
sShapeCornersBottomRightRadius dimension 右下角的圆角半径 默认0dp
sShapeStrokeWidth dimension 边框宽度 默认0dp
sShapeStrokeDashWidth dimension 虚线宽度 默认0dp
sShapeStrokeDashGap dimension 虚线间隙宽度 默认0dp
sShapeStrokeColor color 边框颜色 默认0dp
sLeftTextBackground reference 左边textView的背景
sCenterTextBackground reference 中间textView的背景
sRightTextBackground reference 右边textView的背景
sLeftTextGravity enum 左边TextView内文字对齐方式
left(左对齐)
center(居中)
right(右对齐)
默认left
sCenterTextGravity enum 中间TextView内文字对齐方式
left(左对齐)
center(居中)
right(右对齐)
默认left
sRightTextGravity enum 右边TextView内文字对齐方式
left(左对齐)
center(居中)
right(右对齐)
默认left
sLeftIconShowCircle boolean 左边ImageView是否显示为圆形 默认false
sRightIconShowCircle boolean 右边ImageView是否显示为圆形 默认false

黑格尔曾说过:存在即合理。SuperTextView的出现应该就是某种需求下的产物。

4、更新日志

意见反馈

STV&RxHttp交流群

或者手动加QQ群:688433795

如果遇到问题或者好的建议,请反馈到:issue[email protected] 或者[email protected]

如果觉得对你有用的话,点一下右上的星星赞一下吧!

代码是最好的老师,更多详细用法请查看 demo 🐾

License

         Copyright 2016 Allen

        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.

Comments
  • 建议

    建议

    在OnClickListener里把当前点击的View传回来,原因:如果用代码动态设置superTextView的数量时,他的点击事件也是for循环里添加的,有些需求是点击后 回调处理的,还需要把动态创建的superTextView变成成员变量才能继续对他做设置,不是很灵活,如果把当前View 直接传回来就能解决这个问题,动态创建很正常如果我有10个或者更多的item 我不可能全部写在xml里 这样太不优雅了

    opened by huyanminggithub 8
  • 怎么在右边添加头像图片+箭头

    怎么在右边添加头像图片+箭头

    例如(模板样子):

    帐号 用户头像 >

    开发的工程中,需要 【用户头像+箭头】的组合 我发现 在xml中 可以通过sRightTextStringRightIconRes,修改用户头像的图片; 但是在代码中确无法修改用户头像,请问在代码中我该怎么修改。

    我用的是Picasso加载图片,我发现SuperTextView,只有rightImageViewId Picasso.with(this) .load("http://i.imgur.com/DvpvklR.png") .placeholder(R.drawable.ease_default_image) .into((ImageView) stvGroupChatAvatar.getView(SuperTextView.rightImageViewId));

    opened by rmtic 7
  • stv命名空间

    stv命名空间

    <com.allen.library.SuperTextView
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    stv:sCenterBottomTextColor="@color/colorAccent"
                    stv:sCenterBottomTextString="限额说明>>"
                    stv:sCenterTopTextString=" "
                    stv:sCenterViewGravity="left_center"
                    stv:sLeftBottomTextString="招商银行(8888)"
                    stv:sLeftIconRes="@drawable/bank_zhao_shang"
                    stv:sLeftTopTextString="银行卡支付"
                    stv:sLeftViewGravity="left_center"
                    stv:sRightCheckBoxRes="@drawable/circular_check_bg"
                    stv:sRightViewType="checkbox" />
    

    建议将stv命名空间改为app. 因为Android Studio自动导入时,容易将stv命名为xmlns:stv="http://schemas.android.com/tools". 而实际上看了demo的stv为xmlns:stv="http://schemas.android.com/apk/res-auto", 其实就是xmlns:app="http://schemas.android.com/apk/res-auto"

    opened by xiaobailong24 6
  • 为何感觉布局的下边距比上边距要大

    为何感觉布局的下边距比上边距要大

    如图

    image

    <com.allen.library.SuperTextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:sCenterSpaceHeight="@dimen/common_margin_padding"
             app:sLeftTextColor="@color/grey_999"
             app:sLeftTextString="测试"
             app:sLeftTopTextColor="@color/grey_999"
             app:sLeftTopTextSize="10sp"
             app:sLeftTopTextString="测试"
             app:sLeftViewGravity="left_center"
             app:sLeftViewMarginLeft="@dimen/common_margin_padding"
             app:sLeftTextSize="13sp"
             app:sRightTextColor="@color/black_333"
             app:sRightTextSize="13sp"
             app:sRightTextString="测试"
             app:sRightTopTextColor="@color/grey_999"
             app:sRightTopTextSize="10sp"
             app:sRightTopTextString="测试" />
    
    opened by lvyandev 4
  • superButton 代码中设置属性无效

    superButton 代码中设置属性无效

    SuperButton btnLogin; btnLogin.setShapeSelectorNormalColor(getResources().getColor(R.color.text_default_color)); btnLogin.setShapeSelectorPressedColor(getResources().getColor(R.color.btn_normalColor)); btnLogin.setShapeUseSelector(true);

    但是在布局中设置能生效

    opened by ADsuper 4
  • java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps

    java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps

    java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:946) at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:953) at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:76) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:164) at android.graphics.Canvas.drawBitmap(Canvas.java:1658) at ShapeLinearLayout.dispatchDraw(ShapeLinearLayout.kt:44)

    opened by billdizl 0
Releases(2.4.6)
  • 2.4.5(Feb 3, 2021)

  • 2.4.2(Oct 16, 2019)

  • 2.4.1(Oct 11, 2019)

  • 2.4.0(Oct 10, 2019)

    ShapeFrameLayout
    ShapeLinearLayout
    ShapeRelativeLayout
    ShapeCardView
    ShapeConstraintLayout
    

    以上控件,新增阴影设置属性,详细用法见demo

    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Sep 10, 2019)

    新增常用 ShapeXXXView

    ShapeTextView
    ShapeButton
    ShapeFrameLayout
    ShapeLinearLayout
    ShapeRelativeLayout
    ShapeCardView
    ShapeConstraintLayout)
    
    Source code(tar.gz)
    Source code(zip)
  • 2.2.4(Jun 5, 2019)

    1: 新增ShapeBuilder 2: 优化SuperBttton 3: SuperTextView支持ShapeBuilder 4: SuperTextView新增文字区域整体点击事件

    • ShapeBuilder用法如下:
            new ShapeBuilder()
                    .setShapeType(shapeType)
                    .setShapeCornersRadius(cornersRadius)
                    .setShapeCornersTopLeftRadius(cornersTopLeftRadius)
                    .setShapeCornersTopRightRadius(cornersTopRightRadius)
                    .setShapeCornersBottomRightRadius(cornersBottomRightRadius)
                    .setShapeCornersBottomLeftRadius(cornersBottomLeftRadius)
                    .setShapeSolidColor(solidColor)
                    .setShapeStrokeColor(strokeColor)
                    .setShapeStrokeWidth(strokeWidth)
                    .setShapeStrokeDashWidth(strokeDashWidth)
                    .setShapeStrokeDashGap(strokeDashGap)
                    .setShapeUseSelector(useSelector)
                    .setShapeSelectorNormalColor(selectorNormalColor)
                    .setShapeSelectorPressedColor(selectorPressedColor)
                    .setShapeSelectorDisableColor(selectorDisableColor)
                    .setShapeSizeWidth(sizeWidth)
                    .setShapeSizeHeight(sizeHeight)
                    .setShapeGradientType(gradientType)
                    .setShapeGradientAngle(gradientAngle)
                    .setShapeGradientUseLevel(gradientUseLevel)
                    .setShapeGradientCenterX(gradientCenterX)
                    .setShapeGradientCenterY(gradientCenterY)
                    .setShapeGradientStartColor(gradientStartColor)
                    .setShapeGradientCenterColor(gradientCenterColor)
                    .setShapeGradientEndColor(gradientEndColor)
                    .into(view);
    
    Source code(tar.gz)
    Source code(zip)
  • 2.2.3(Apr 27, 2019)

  • 2.2.2(Apr 21, 2019)

  • 2.2.1(Apr 12, 2019)

  • 2.2.0(Apr 3, 2019)

  • 2.1.8(Aug 14, 2018)

    修复字体颜色不支持selector的问题Issues描述

    1、布局中TextView颜色使用selector

                <com.allen.library.SuperTextView
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    stv:sLeftTextColor="@color/selector_stv_text_color"
                    stv:sLeftTextString="账号与安全"
                    stv:sRightIconRes="@drawable/arrow_right_red"
                    stv:sRightTextString="已保护"
                    stv:sRightTextColor="@color/selector_stv_text_color"
                    stv:sRightTvDrawableLeft="@drawable/v1"
                    stv:sUseShape="true" />
    

    2、代码中TextView颜色使用selector(使用getResources().getColorStateList(R.color.selector_stv_text_color))

         superTextView
                   .setXXXTextColor(getResources().getColorStateList(R.color.selector_stv_text_color));
    
    Source code(tar.gz)
    Source code(zip)
  • 2.1.7(May 4, 2018)

    新增动态设置分割线颜色的方法

    superTextView.setTopDividerLineColor(getResources().getColor(R.color.colorAccent))
                 .setBottomDividerLineColor(getResources().getColor(R.color.colorPrimary));
    
    Source code(tar.gz)
    Source code(zip)
  • 2.1.6(Jan 22, 2018)

  • 2.1.5(Oct 14, 2017)

    1、左右ImageView新增圆形图片的支持(内置CircleImageView)

    <attr name="sLeftIconShowCircle" format="boolean" />
    <attr name="sRightIconShowCircle" format="boolean" />
    

    2、取消maxEms和maxLines的默认值,需要的时候自行配置 3、取消xml中配置字体加粗属性,变为代码控制

    Source code(tar.gz)
    Source code(zip)
  • 2.1.4(Sep 1, 2017)

    1、新增动态设置分割线是否显示

                    superTextView
                            .setTopDividerLineVisibility(View.GONE)
                            .setBottomDividerLineVisibility(View.GONE);
    

    2、新增动态设置左中右文字的对齐方式

                    superTextView
                            .setLeftTextGravity(Gravity.LEFT)
                            .setCenterTextGravity(Gravity.LEFT)
                            .setRightTextGravity(Gravity.LEFT);
    
    Source code(tar.gz)
    Source code(zip)
  • 2.1.3(Aug 24, 2017)

    1、SuperTextView新增左中右TextView的drawableLeft和DrawableRight的宽高可在xml中配置 issues61 2、修复sLeftViewWidth宽度单位问题 3、修复xxxLines,保证设置多行后不会占行的bug

    Source code(tar.gz)
    Source code(zip)
  • 2.1.2(Aug 14, 2017)

    1、SuperTextView新增获取TextView的方法,用于设置一些不常用的属性

            superTextView.getLeftTopTextView();
            superTextView.getLeftTextView();
            superTextView.getLeftBottomTextView();
            superTextView.getCenterTopTextView();
            superTextView.getCenterTextView();
            superTextView.getCenterBottomTextView();
            superTextView.getRightTopTextView();
            superTextView.getRightTextView();
            superTextView.getRightBottomTextView();
    

    2、默认显示字符从原来的10修改为15

    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Aug 12, 2017)

    1、SuperTextView所有setText方法参数String修改为CharSequence

    目的是为了支持:SpannableStringBuilder、String.format、Html.fromHtml

    2、SuperTextView与shape相关的属性均可代码动态设置

            superTextView.setShapeCornersRadius(20)
                    .setShapeCornersTopLeftRadius(20)
                    .setShapeCornersBottomLeftRadius(20)
                    .setShapeCornersTopRightRadius(20)
                    .setShapeCornersBottomRightRadius(20)
                    .setShapeStrokeColor(getResources().getColor(R.color.colorPrimary))
                    .setShapeStrokeWidth(1)
                    .setShapeSrokeDashWidth(1)
                    .setShapeStrokeDashGap(5)
                    .setShapeSolidColor(getResources().getColor(R.color.white))
                    .setShapeSelectorNormalColor(getResources().getColor(R.color.red_btn))
                    .setShapeSelectorPressedColor(getResources().getColor(R.color.gray))
                    .useShape();//设置完各个参数之后这句调用才生效
    

    设置完各个参数之后这句useShape()调用才生效

    3、SuperTextView新增动态设置背景的方法

            superTextView
                    .setSBackground(getResources().getDrawable(R.drawable.selector_white))

    

    4、SuperButton所有属性均提供代码动态设置

          /**
             * 所有属性均可用代码动态实现
             * 以下只是展示部分方法 可根据需求选择不同的方法
             */
            superButton.setShapeType(SuperButton.RECTANGLE)
                    .setShapeCornersRadius(20)
                    .setShapeSolidColor(getResources().getColor(R.color.colorAccent))
                    .setShapeStrokeColor(getResources().getColor(R.color.colorPrimary))
                    .setShapeStrokeWidth(1)
                    .setShapeSrokeDashWidth(2)
                    .setShapeStrokeDashGap(5)
                    .setTextGravity(SuperButton.TEXT_GRAVITY_RIGHT)
                    .setShapeUseSelector(true)
                    .setShapeSelectorPressedColor(getResources().getColor(R.color.gray))
                    .setShapeSelectorNormalColor(getResources().getColor(R.color.red_btn))
                    .setShapeSelectorDisableColor(getResources().getColor(R.color.colorPrimary))
                    .setUseShape();
            // TODO: 2017/8/12 动态设置切记需要在最后调用 setUseShape 才能对设置的参数生效
    
    
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Aug 6, 2017)

  • 2.0.9(Jul 27, 2017)

    新增设置左、中、右text的background

    stv:sLeftTextBackground
    stv:sCenterTextBackground
    stv:sRightTextBackground
    

    以下是根据这些background实现的效果

    image

    Source code(tar.gz)
    Source code(zip)
  • 2.0.8(Jul 25, 2017)

  • 2.0.6(Jul 21, 2017)

  • 2.0.5(Jul 18, 2017)

  • 2.0.4(Jul 17, 2017)

  • 2.0.3(Jul 12, 2017)

    新增switch、checkbox、leftIconIv、rightIconIv的点击事件回调

    supertextview
              .setSwitchCheckedChangeListener(new SuperTextView.OnSwitchCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                }
            }).setCheckBoxCheckedChangeListener(new SuperTextView.OnCheckBoxCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                }
            }).setLeftImageViewClickListener(new SuperTextView.OnLeftImageViewClickListener() {
                @Override
                public void onClickListener() {
                }
            }).setRightImageViewClickListener(new SuperTextView.OnRightImageViewClickListener() {
                @Override
                public void onClickListener() {
                }
            });
    
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Jul 11, 2017)

    新增:支持圆角设置(使用的圆角首先要配置sUseShape=true,然后配置相关属性即可)

    新增SuperButton(实现shape的大部分属性,都可在SuperButton的xml中配置)

    部分bug修复

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Jul 5, 2017)

  • 2.0.0(Jul 4, 2017)

  • 1.1.2(Apr 7, 2017)

Owner
Allen
Great People Share Knowledge!
Allen
Mentions-TextView - Make Mentions and hashtags clickable in Textview

Mentions Textview Custome Textview with Mentions and hashtags being clickable. D

null 2 Jan 9, 2022
Android's TextView that can expand/collapse like the Google Play's app description

ExpandableTextView ExpandableTextView is an Android library that allows developers to easily create an TextView which can expand/collapse just like th

Manabu S. 4k Dec 28, 2022
A library to show emoji in TextView, EditText (like WhatsApp) for Android

Discontinued This projected is discontinued. Please consider using other alternative, i.e EmojiCompat. Contact me if you want to continue working on a

Hieu Rocker 3.6k Jan 5, 2023
Android experiment showing a sinking TextView

Titanic is an Android experiment reproducing this effect.

Romain Piel 1.8k Dec 15, 2022
Advanced Android TextView

Advanced Android TextView Companion app for my Advanced Android TextView talk, demostrating: Animated CompoundDrawable Text shadow Custom font Non-bre

Chiu-Ki Chan 1.2k Dec 9, 2022
This is based on an open source autosizing textview for Android.

SizeAdjustingTextView This is based on an open source autosizing textview for Android I found a few weeks ago. The initial approach didn't resize mult

Elliott Chenger 255 Dec 29, 2022
An extension of Android's TextView, EditText and Button that let's you use the font of your choice

AnyTextView (deprecated) Note: AnyTextView is no longer being maintained. I recommend replacing AnyTextView with the Calligraphy library instead. Frus

Hans Petter Eide 165 Nov 11, 2022
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Linden 147 Nov 20, 2022
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText

Simple Linkable Text Simple way to create link text, such as @username or #hashtag, in Android TextView and EditText Installation Gradle Add dependenc

Aditya Pradana Sugiarto 76 Nov 29, 2022
Lightweight android library for highlighting sections of a textview, with optional callbacks.

Linker Lightweight android library for highlighting Strings inside of a textview (ignoring case), with optional callbacks. Language: Java MinSDK: 17 J

Josh Gainey 35 Apr 30, 2022
Android slanted TextView.

SlantedTextView Android slanted TextView . 中文版 Preview Gradle compile 'com.haozhang.libary:android-slanted-textview:1.2' XML Layout <com.haozhang.lib.

Hand Zhang 2.2k Dec 26, 2022
() An Android TextView with a shimmering effect

Shimmer for Android This library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into y

Romain Piel 2k Jan 7, 2023
An Android TextView that always displays an auto refreshing relative time span with respect to a reference time

android-ago This library provides RelativeTimeTextView, a custom TextView that takes a reference time and always displays the relative time with respe

Kiran Rao 658 Dec 21, 2022
Build valid HTML for Android TextView

HTML Builder Build valid HTML for Android TextView. Description There is a lovely method on the android.text.Html class, fromHtml(), that converts HTM

Jared Rummler 527 Dec 25, 2022
ExpandableTextView - Read More TextView for Android

ExpandableTextView Read More TextView for Android Usage Gradle dependencies { implementation 'com.wayne.expandabletextview:expandable-textview:1.1

You kwangwoo 31 Oct 12, 2022
Animation effects to text, not really textview

HTextView Animation effects with custom font support to TextView see iOS Effects see Flutter Effects Screenshot type gif Scale Evaporate Fall Line Typ

hanks 5.5k Jan 5, 2023
A TextView that automatically resizes text to fit perfectly within its bounds.

AutoFitTextView A TextView that automatically resizes text to fit perfectly within its bounds. Usage dependencies { compile 'me.grantland:autofitt

Grantland Chew 4.2k Jan 1, 2023
A Custom TextView with trim text

ReadMoreTextView A Custom TextView with trim text Download To add the ReadMoreTextView library to your Android Studio project, simply add the followin

Borja B. 1.7k Dec 29, 2022
AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.

AutoLinkTextView Deprecated Please use the new version of AutoLinkTextView AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URL

Arman 1.1k Nov 23, 2022