Android 无法显示TextView的文本阴影
我想为我的文本制作文本阴影效果。所以我使用TextView的阴影属性。但我不知道为什么它不能显示阴影,我已经检查了Android Studio布局预览和真实设备Galaxy S3,但什么都没有发生 帮帮我Android 无法显示TextView的文本阴影,android,android-layout,Android,Android Layout,我想为我的文本制作文本阴影效果。所以我使用TextView的阴影属性。但我不知道为什么它不能显示阴影,我已经检查了Android Studio布局预览和真实设备Galaxy S3,但什么都没有发生 帮帮我 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white">
<TextView android:textColor="@color/black"
android:layout_width="wrap_content"
android:text="Text Shadow"
android:layout_height="wrap_content"
android:padding="2dp"
android:shadowColor="#7F000000"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="1" />
</RelativeLayout>
只需尝试将一个名为shadow\u bg.xml的xml文件放置到您的文本视图中即可
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:endColor="#b0000000"
android:startColor="#00000000" />
</shape>
活动\u main.xml
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Text Shadow Example2"
android:background="@drawable/shadow_bg"
android:textColor="#FBFBFB"
android:textSize="28dp"
android:textStyle="bold" />
这对我来说很好。希望它对您也能正常工作。尝试
android:shadowDx=“12”android:shadowDy=“12”android:shadowRadius=“8”
什么都没有发生……仍然没有找到文本颜色为黑色,文本阴影颜色为半黑色的原因<代码>你能分辨出区别吗?尝试将阴影颜色设置为红色,仅用于实验。。。所以你可以清楚地看到它(当然,这取决于你的背景主色)。是的,这就是原因。因为我已经在设备上检查过了,使用小字体,它几乎是一样的,我认为它不起作用
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Text Shadow Example2"
android:background="@drawable/shadow_bg"
android:textColor="#FBFBFB"
android:textSize="28dp"
android:textStyle="bold" />