我想让文字发光,就像在this question中一样,但是在具有透明背景的按钮文本中,在具有其他背景的布局中(png来自drawable)。有没有办法做到这一点?解决方案是一天吗?我在4.1.2设备上尝试了一个简单的测试而没有看到任何结果。这是我的代码:
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>
这是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>
从this tutorial获得。请有人帮帮我吗?
答案 0 :(得分:1)
您可以通过在 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>
和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>