android TextView(5)-TextView一些其他常用效果

xiaoxiao2021-02-28  86

实现跑马灯效果的TextView

只需要在布局文件中加上属性

android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusable="true" android:focusableInTouchMode="true"

如下

<TextView android:id="@+id/txtOne" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="18sp" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusable="true" android:focusableInTouchMode="true" android:text="你整天说着日了狗日了狗,但是你却没有来,呵呵呵呵呵呵呵呵呵呵~"/>

设置TextView字间距和行间距

字间距:

android:textScaleX:控制字体水平方向的缩放,默认值1.0f,值是float Java中setScaleX(2.0f);

行间距:

android:lineSpacingExtra:设置行间距,如"3dp" android:lineSpacingMultiplier:设置行间距的倍数,如"1.2"

Java代码中可以通过: setLineSpacing方法来设置

自动换行

自动换行通过 android:singleLine 设置,默认为 false。 如需要自动换行,可以用: android:singleLine = "false" 如果要在一行显示完,不换行,可以用: android:singleLine = "true" 多行显示不完,使用maxLines属性
转载请注明原文地址: https://www.6miu.com/read-57674.html

最新回复(0)