漳州市建设网站,ppt素材,宁乡的网站建设,北流做网站1、带阴影的TextView
①、 android:shadowColor“color/black” 设置阴影颜色#xff0c;需要与shadowRadius一起使用 ②、android:shadowRadius“3.0” 设置阴影模糊程度#xff0c;设为0.1会变成字体颜色#xff0c;建议设置3.0 ③、android:shadowDx“10” 设置阴影在水…1、带阴影的TextView
①、 android:shadowColor“color/black” 设置阴影颜色需要与shadowRadius一起使用 ②、android:shadowRadius“3.0” 设置阴影模糊程度设为0.1会变成字体颜色建议设置3.0 ③、android:shadowDx“10” 设置阴影在水平方向的偏移水平方向阴影开始的横坐标位置 ④、android:shadowDy“10” 设置阴影在竖直方向的偏移竖直方向阴影开始的纵坐标位置
实例 androidx.appcompat.widget.AppCompatTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World!android:shadowRadius3.0android:shadowColorcolor/blackandroid:shadowDx10android:shadowDy10app:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparent /2、跑马灯效果的TextView
①、android:singleLine“true” 内容当行显示 ②、 android:focusable“true” 是否可以获取焦点 ③、android:focusableInTouchMode“true” 控制视图在触摸模式下是否可以获取焦点 ④、 android:ellipsize“marquee” 在什么位置添加省略文本 ⑤、android:marqueeRepeatLimit“marquee_forever” 字幕动画重复次数
实现方式1新建一个textview继承AppCompatTextView重写isFocused() 方法
public class CustomTextView extends AppCompatTextView {public CustomTextView(NonNull Context context) {super(context);}public CustomTextView(NonNull Context context, Nullable AttributeSet attrs) {super(context, attrs);}public CustomTextView(NonNull Context context, Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}Overridepublic boolean isFocused() {return true;}
}xml中使用自定义的view com.lxd.xdplayer.CustomTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!android:singleLinetrueandroid:focusabletrueandroid:focusableInTouchModetrueandroid:ellipsizemarqueeandroid:marqueeRepeatLimitmarquee_foreverapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparent/实现方式2在xml布局文件的 AppCompatTextView中添加 androidx.appcompat.widget.AppCompatTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!android:singleLinetrueandroid:focusabletrueandroid:focusableInTouchModetrueandroid:ellipsizemarqueeandroid:marqueeRepeatLimitmarquee_foreverapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentrequestFocus//androidx.appcompat.widget.AppCompatTextView