Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add shadow on custom text?

i tried with xml file and with code to add shadow to custom font without any success

my code is

TextView text=(TextView)findViewById(R.id.text1);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/gillsans.ttf");
text.setTypeface(tf);
like image 703
Akram Avatar asked Mar 10 '12 13:03

Akram


People also ask

How do you add a shadow to text in Photoshop 2022?

To add a drop shadow to text or images in Photoshop, first select the desired layer, then click the “FX” icon at the bottom of the Layers panel. From the provided Layer Styles, select “Drop Shadow” to apply it to your text or image.

Can I use CSS text-shadow?

The text-shadow CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its decorations . Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color.

How do you add a shadow to text in Illustrator?

Open the menu labeled Effect and navigate to the submenu labeled Stylize. There you should choose the option labeled Drop Shadow. There is a checkbox labeled Preview. Activate it in the Drop Shadow dialog box.


2 Answers

use this:

Activity.class :

    TextView text=(TextView)findViewById(R.id.text1);
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/gillsans.ttf");
    text.setTypeface(tf);
////////////

    Shader textShader=new LinearGradient(2, 0, 4, 60,
                    new int[]{Color.parseColor("#b4e391"),Color.parseColor("#61c419"),Color.parseColor("#b4e391")},
                    new float[]{0, 3,1}, TileMode.MIRROR);
            text.getPaint().setShader(textShader);

main.xml:

 <TextView
            android:id="@+id/text1"
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:shadowDx="5"
            android:shadowDy="5"
            android:layout_marginRight="42dp"
            android:layout_marginTop="-10dp"
            android:layout_gravity="right|center_vertical"

            android:shadowColor="#67587686"

            android:shadowRadius="3"
            android:textSize="25dp"
            android:text="99%" />
like image 173
ρяσѕρєя K Avatar answered Nov 15 '22 07:11

ρяσѕρєя K


Did you set the related shadow attributes?

android:shadowColor
android:shadowDx
android:shadowDy
android:shadowRadius
like image 34
stefan bachert Avatar answered Nov 15 '22 06:11

stefan bachert