user2508815
user2508815

Reputation: 83

Android How does TextView Shadow work

I have textview with shadow to show,I put parameters of Shadow ShadowX and ShadowY and ShadowRadius like in following XML code

 <TextView
            android:id="@+id/Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowColor="#e41919"
            android:shadowRadius="0.6"
            android:text="@string/nader"
            android:textColor="#e1e1e1"
            android:textStyle="bold" />

but I don't know that how Shadow X ,Shadow Y and Shadow Radius work in background and how android evaluate these parameters values conceptually?

android:shadowDx – specifies the X-axis offset of shadow. You can give -/+ values, where -Dx draws a shadow on the left of text and +Dx on the right

android:shadowDy – it specifies the Y-axis offset of shadow. -Dy specifies a shadow above the text and +Dy specifies below the text.

android:shadowRadius – specifies how much the shadow should be blurred at the edges. Provide a small value if shadow needs to be prominent.

how does android logically use these above attribute values without specifying values in any format like ,please send me any tutorial URL about these attributes

dp pixel

if you have any tutorial and reference about shadow parameter then please help and send me the Blogs URL tutorial about these properties of Shadow

Upvotes: 5

Views: 17521

Answers (3)

ema3272
ema3272

Reputation: 1051

Experimenting with different values, I noticed that

  • a negative value for dx moves (i.e. translates) the whole shadow to the left
  • a positive value for dx moves (i.e. translates) the whole shadow to the right
  • a negative value for dy moves (i.e. translates) the whole shadow upwards
  • a positive value for dy moves (i.e. translates) the whole shadow downwards

The distance is determined by value: the greater the absolute value, the greater the distance.

Upvotes: 0

Ramesh Prajapati
Ramesh Prajapati

Reputation: 662

Add the attributes in the TextView XML:

android:shadowColor="#ff6ccDze0"
android:shadowRadius="5"
android:shadowDy="6"
android:shadowDx="7"

Upvotes: 0

Saritha G
Saritha G

Reputation: 2608

Please Refer the following link:

http://android--code.blogspot.in/2015/05/android-textview-text-shadow.html

You have to take the 3-4 textview's in yout xml file, then change the shadowDx, shadowDy and color of the shadow for each textview, then you will observe the difference.

Upvotes: 2

Related Questions