美文网首页Android开发经验谈Android开发Android开发
Android TextView 实现跑马灯、查看全文、字间距修

Android TextView 实现跑马灯、查看全文、字间距修

作者: d74f37143a31 | 来源:发表于2018-12-04 17:08 被阅读23次

跑马灯

**[Android 自定义 View 实现跑马灯效果](https://blog.csdn.net/ITxiaodong/article/details/79885395)**

字间距、行间距

    如在XML中:
        ```
        android:letterSpacing="0.05"
        android:lineSpacingExtra="1dp"
        ```
    在代码中动态设置,如下:
        ```
        textView.setLetterSpacing(0.05);
        textView.setLineSpacing(float add, float mult);
            参数`add`表示要增加的行间距数值,对应`android:lineSpacingExtra`属性;
            参数`mult`表示行间距倍数,对应`android:lineSpacingMultiplier`属性。
        ```

阴影

    1. android:shadowColor:阴影的颜色
    2. android:shadowDx:水平方向上的偏移量
    3. android:shadowDy:垂直方向上的偏移量
    4. android:shadowRadius:是阴影的的半径大小
    [Android TextView加上阴影效果](https://blog.csdn.net/hewence1/article/details/39993415)
### span 
    **[Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性](https://blog.csdn.net/jdsjlzx/article/details/19122103)**
    **[Android 利用 SpannableString 实现微信 @朋友 整块删除功能](https://blog.csdn.net/ITxiaodong/article/details/82229643)**

系统复制

    `android:textIsSelectable="true"` 需要注意版本兼容

查看、展开全文

    **[Android尾部带“查看更多”的TextView](http://www.voidcn.com/article/p-pwsidgus-zg.html)**

中粗细???

> 有知道的,望告知

图文:动态控制间距(适配不方便)

    XML 布局
    ```
    android:drawableEnd="@drawable/home_adapter_item_collect"
    android:drawablePadding="6dp"
    ```
    Java 代码 
    ```
    if (post.collect == 0){
        Drawable drawable= mContext.getResources().getDrawable(R.drawable.post_un_collect);
        // 这一步必须要做,否则不会显示设置的图片.
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        textView.setCompoundDrawables(drawable,null,null,null);
        textView.setText("收藏");
    }else {
        Drawable drawable= mContext.getResources().getDrawable(R.drawable.post_collect);
        // 这一步必须要做,否则不会显示设置的图片.
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        textView.setCompoundDrawables(drawable,null,null,null);
        txtView.setText("已收藏");
    }
    ```

参考:

https://www.cnblogs.com/plokmju/p/Android_UI_TextView.html
https://www.jianshu.com/p/afbee500083b

相关文章

网友评论

    本文标题:Android TextView 实现跑马灯、查看全文、字间距修

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