4

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?

Community
  • 1
  • 1
lis
  • 670
  • 1
  • 13
  • 32

1 Answers1

1

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>
CrazyLearner
  • 782
  • 3
  • 11
  • 28
  • yeah, thank you, that's working with all colors! Do you know, how I can manipulate it in Java too? If I set `tv.setShadowLayer(8, 0, 0, R.drawable.Green);` (tv is the TextView without the attributes shadow...) in Java, the shadow will be grey instead of green (on white background). Do you know why? – lis Nov 27 '13 at 15:08
  • 1
    instead of tv.setShadowLayer(8, 0, 0, R.drawable.Green), use this: tv.setShadowLayer(8, 0, 0, Color.Green), certainly this will work. – CrazyLearner Nov 27 '13 at 17:53
  • yeah, that works! And I get customer colors by using `Color.rgb(r, g, b)` :) thank you!!! :) – lis Nov 28 '13 at 17:31