TextView text shadow shadow

xml implementation

<TextView
    android:id="@+id/tv5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:gravity="center"
    android:shadowColor="#FF0000"
    android:shadowDx="1"
    android:shadowDy="2"
    android:shadowRadius="3"
    android:text="长按拖动可互换位置"
    android:textColor="#FFFFFFFF"
    android:textSize="16sp"/>
  • android:shadowDx The horizontal offset of the shadow is the distance to the right
  • android:shadowDy The vertical offset of the shadow is the distance moved downward
  • android:shadowColor shadow color
  • android:shadowRadius The range of the shadow is the degree of transparency and diffusion of the shadow

Code implementation: setShadowLayer

<TextView
    android:id="@+id/tv6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:gravity="center"
    android:text="长按拖动可互换位置"
    android:textColor="#FFFFFFFF"
    android:textSize="16sp"/>
tv6.setShadowLayer(3,1,2, Color.RED);
//public void setShadowLayer(float radius, float dx, float dy, int color)

Guess you like

Origin blog.csdn.net/sinat_31057219/article/details/132598008