How to adjust shadow around TextView

<TextView
            android:id="@+id/text"
            android:layout_width="225dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_toRightOf="@+id/left"
            android:background="@anim/chatitemshaodow"
            android:fontFamily="calibri"
            android:padding="8dp"
            android:textColor="#636363"
            android:textSize="17dp" />

These are my controls TextViewand I want to set the shadow around TextView. I can set Showdown to text in TextView, but I cannot set the shadow round to TextView.

I want to set the textview tag as a given screen in android. enter image description here

+4
source share
3 answers

Create a new drawable resource file. I called my two_sided_border.xml.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item>
    <shape>
        <solid android:color="@color/black" />
    </shape>
</item>
<!-- This is the main color -->
<item android:bottom="2dp" android:right="2dp">
    <shape>
        <solid android:color="@color/green" />
    </shape>
</item>
</layer-list>

Then use this as a background for your text view.

<TextView
    android:id="@+id/t"
    android:background="@drawable/two_sided_border"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"/>

Your colors and sizes (indents, text size) can be adjusted to fit your needs.

Two great links:

how to make a move for three sides for the shape in android?

And he borrowed some code from me:

Android

ps , , .

textview

+5

, android: shadowColor, android: shadowDx, android: shadowDy, android: shadowRadius; setShadowLayer()?

:

<style name="Text">
    <item name="android:paddingLeft">4px</item>
    <item name="android:paddingBottom">4px</item>
    <item name="android:textColor">#ffffffff</item>
    <item name="android:textSize">12sp</item>
    <item name="android:shadowColor">#000000</item>
    <item name="android:shadowDx">1</item>
    <item name="android:shadowDy">1</item>
    <item name="android:shadowRadius">1</item>
  </style>

1:

<TextView android:id="@+id/text"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       style="@style/Text"
       android:gravity="center" />

2:

TextView text= (TextView) findViewById(R.id.text);
infoTextView.setTextAppearance(getApplicationContext(),  
       R.style.Text);
+2

It was a job for me

Android: shadowRadius = "3" android: shadowDy = "- 4"

0
source

All Articles