2

I want to add a white stroke to black text inside a button. I can figure out to do this with regular textview but not when it comes to a button.

Thi is regarding Xml android studio btw.

activity_main.xml:

   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="5dip"
    android:background="@drawable/login_button_style"
    android:text="Log Ind"
    android:id="@+id/button"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/editTextPass"
    android:layout_alignEnd="@+id/editTextPass"
    android:clickable="true" /><![CDATA[
/>

login_button_style.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#d7d7d7"/>
<corners
    android:bottomRightRadius="15dp"
    android:bottomLeftRadius="15dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp"/>
<stroke android:color="#d10f0f" android:width="3dp" />

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="shadoweffect">
        <item name="android:paddingLeft">4px</item>
        <item name="android:paddingBottom">4px</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textSize">25sp</item>
        <item name="android:shadowColor">#000000</item>
        <item name="android:shadowDx">0</item>
        <item name="android:shadowDy">0</item>
        <item name="android:shadowRadius">3</item>
    </style>

</resources>

enter image description here

can someone please enlighten me?

Nulle
  • 1,301
  • 13
  • 28

1 Answers1

0

Look at this answer to a similar question on how to make a border. He creates a new file that is a shape of just that color then stores it as a drawable to be used as the background image https://stackoverflow.com/questions/7690416/android-border-for-button

Just change the color to white and there you go

EDIT:

Actually seeing now. You want the letters to be outlined in white.

So my best guess would be to draw the entire image with the text and border up in Photoshop/Sketch. And then save that as a drawable. To set for your buttons background. Make sure to set the buttons text to just quotes since you will already have the text in the Photoshop mockup

android:text = ""
Community
  • 1
  • 1