2

I would like to add a border independently around each letter of my Textview like this example :

enter image description here

Actually I have a basic TextView in purple , but I would like to add yellow border as you can see on this image.

Here is my actual XML of my Textview which is the same as the picture but WITHOUT yellow border around letters :

<TextView
    android:id="@+id/Coins"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="9dp"
    android:layout_marginStart="150dp"
    android:layout_marginTop="116dp"
    android:fontFamily="@font/montserratbold"
    android:textColor="#a51ebf"
    android:textSize="20dp"
    app:layout_constraintBottom_toBottomOf="@+id/box"
    app:layout_constraintEnd_toEndOf="@+id/box"
    app:layout_constraintHorizontal_bias="0.55"
    app:layout_constraintStart_toStartOf="@+id/box"
    app:layout_constraintTop_toTopOf="@+id/box"
    app:layout_constraintVertical_bias="0.25" />

I tried many solutions but nothing work especially , let me know if you have something. Thanks !

plase
  • 361
  • 1
  • 3
  • 9
Manu13k
  • 326
  • 1
  • 6
  • 20
  • If the text is not mutable i.e. if it doesn't change try using an ImageView with the said image. If not you need to write a custom textview where you can divide one textview into individual textviews and apply background to them – HawkPriest Jul 02 '18 at 13:49
  • Try this solution. https://stackoverflow.com/questions/39106454/add-opaque-shadow-outline-to-android-textview – Arvind Jul 02 '18 at 13:49
  • @HawkPriest Unfortunately , this text is mutable , it changes everytime. – Manu13k Jul 02 '18 at 13:53
  • @Manu13k Are you trying to achieve the stroke property of a text? – ImMathan Jul 02 '18 at 14:03
  • @ImMathan Yes but in a different color , like I said I would like a yellow stroke behid my purple text – Manu13k Jul 02 '18 at 14:06

1 Answers1

1

I "solved" it by adding another Textview at the same position in yellow color and with stroke like this :

TextView textViewShadow = (TextView) findViewById(R.id.textViewShadowId);
    textViewShadow.getPaint().setStrokeWidth(5);
    textViewShadow.getPaint().setStyle(Paint.Style.STROKE);

What do you think ? It is bad for the application ?

EDIT : I Created a custom Textview , now it works you can see the answer here : Android textview outline text

Manu13k
  • 326
  • 1
  • 6
  • 20