1. TextView with shadow
①. android:shadowColor="@color/black"
sets the shadow color and needs to be used with shadowRadius
②. android:shadowRadius="3.0"
sets the shadow blur level. Setting it to 0.1 will change the font color. It is recommended to set 3.0
③. android :shadowDx="10"
sets the offset of the shadow in the horizontal direction, the abscissa position where the shadow starts in the horizontal direction
④, android:shadowDy="10"
sets the offset of the shadow in the vertical direction, the ordinate position where the shadow starts in the vertical direction Location
Example:
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:shadowRadius="3.0"
android:shadowColor="@color/black"
android:shadowDx="10"
android:shadowDy="10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
2. TextView with marquee effect
①, android:singleLine="true"
content is displayed in the line
②, android:focusable="true"
whether it can obtain focus
③, android:focusableInTouchMode="true"
controls whether the view can obtain focus in touch mode
④, android:ellipsize=
Where does "marquee" add omitted text⑤
, android:marqueeRepeatLimit="marquee_forever"
subtitle animation repetition times
Implementation method 1: Create a new textview that inherits AppCompatTextView and overrides the isFocused() method
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);
}
@Override
public boolean isFocused() {
return true;
}
}
Use custom views in xml:
<com.lxd.xdplayer.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
Implementation method 2: Add in AppCompatTextView of xml layout file
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<requestFocus/>
</androidx.appcompat.widget.AppCompatTextView>