2019-09-04 TextView设置显示省略号

1、文字过多,在末尾以省略号结尾
<TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:text="1111111"
        android:textSize="20sp"
        android:ellipsize="end"
        android:maxLines="1"/>
2、给自定义控件添加自定义属性

在res目录下,values中styles.xml文件中定义declare-styleable

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <!--是给自定义控件添加自定义属性用的。-->
    <declare-styleable name="TagsLayout">
        <attr name="tagVerticalSpace" format="dimension"></attr>
        <attr name="tagHorizontalSpace" format="dimension"></attr>
    </declare-styleable>
</resources>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容