Is there a way to add inner shadow to a TextView on Android?

前端 未结 2 678
醉话见心
醉话见心 2020-12-09 05:13

I would like to make an inner shadow on a textview, But I can\'t find any example of that on the web.

Is there any way to do that on Androi

相关标签:
2条回答
  • 2020-12-09 05:26

    If you want the TextView to have inner shadow like this:

    enter image description here

    you have to use 9-patch drawable like this one:

    enter image description here

    Set the 9-patch drawable as the TextView's background.

    The attributes you mention: android:shadowColor, android:shadowRadius, android:shadowDx, android:shadowDy serve other purpose, they create text shadow:

    enter image description here

    0 讨论(0)
  • 2020-12-09 05:37

    If you're looking for inner shadows like these:

    enter image description here

    You could try MagicTextView

        <com.qwerjk.better_text.MagicTextView
            xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text"
            android:textSize="42dp"
            android:textColor="#FFffff00"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:padding="10dp"
            qwerjk:innerShadowDy="3"
            qwerjk:innerShadowColor="#FF000000"
            qwerjk:innerShadowRadius="5"
            android:text="InnerShadow" />
    

    Note: I made this, and am posting more for the sake of future travelers than the OP. It's borderline spam, but being on-topic, perhaps acceptable?

    0 讨论(0)
提交回复
热议问题