How to color my text outline black in xml for android

I want the white text in my Android app to have a black outline. I donโ€™t want to color the text image, so if this is your help, then I donโ€™t know how to do it. I want this to happen using a drawable file in xml format. so that i can highlight the borders of my text in xml?

+6
source share
2 answers

One way is to use shadow :

 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:shadowColor="#000000" android:shadowDx="0.0" android:shadowDy="0.0" android:shadowRadius="2.0" /> 

This gives white text with a black outline. Adjust the radius according to how much you like.

+15
source

From what I can understand, you want a rectangular frame for a TextView fix me if I'm wrong

that

You can set a shape that can be selected (rectangle) as the background for the view.

 <TextView android:text="Some text" android:background="@drawable/black_bhgroung"/> 

And the drawable rectangle black_bhgroung.xml (placed in the res / drawable folder):

 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#00000000" /> <stroke android:width="1dip" android:color="#4fa5d5"/> </shape> 

Hope this helps ...

-1
source

Source: https://habr.com/ru/post/948225/


All Articles