Search code examples
androidbuttontextglow

glowing text on button with transparent background in layout with other background


I want to make text glow, like in this question, but on a text of a button with transparent background in a layout with other background (png from drawable). Is there a way to do this? Is the solution up to day? I tried a simple test on my 4.1.2 device without seeing any results. Here my code:

activity_main.xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@color/Black"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:textColor="@color/White"
        android:layout_width="wrap_content"
        android:text="Glowing Text"
        android:layout_height="wrap_content"
        android:padding="2dp"
        android:shadowColor="@color/White"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="3" />
</LinearLayout>

and this is the color.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="White">#FFF</color>
    <color name="Black">#000</color>
    <color name="Grey">#7F7F7F</color>
    <color name="DarkGrey">#4F4F4F</color>
    <color name="Green">#0F0</color>
    <color name="TransparentGrey">#7F000000</color>
</resources>

got it from this tutorial. Can anybody help me please?


Solution

  • You can get desired result by making the following changes in color.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <drawable name="White">#ffffff</drawable>
        <drawable name="Black">#000000</drawable>
        <drawable name="Grey">#a9a9a9</drawable>
        <color name="DarkGrey">#4F4F4F</color>
        <color name="Green">#0F0</color>
        <color name="TransparentGrey">#7F000000</color>
    </resources>
    

    and in actvity_main.xml

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:background="@drawable/Black"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView android:textColor="@drawable/White"
            android:layout_width="wrap_content"
            android:text="Glowing Text"
            android:layout_height="wrap_content"
            android:padding="2dp"
            android:shadowColor="@drawable/White"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="3" />
    </LinearLayout>