我对自定义 toast 有一个小问题:toast 本身和三个 TextView 的定位按预期工作。我为一个 TextView 设置黑色,为另一个 TextView 设置绿色。绿色的是绿色,带有黑色文本颜色(在深灰色背景上)的是黑色和红色的混合。事实上,内部文本是带有红色阴影的黑色。 对这种行为有什么解释吗?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mytoast_layout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:weightSum="100"
android:orientation="vertical"
android:background="@drawable/toast_frame">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:layout_weight="90"
android:background="#444444" >
<TextView
android:id="@+id/leftview"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="50"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:gravity="center"
android:textColor = "#000000"
android:textAppearance="@style/myToast_small"
android:shadowColor="#BB0000"
android:shadowRadius="2.75" />
<TextView
android:id="@+id/rightview"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="50"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:gravity="center"
android:textColor = "#00FF00"
android:textAppearance="@style/myToast_small"
android:shadowColor="#BB0000"
android:shadowRadius="2.75" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/mainview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="@style/myToast_small"
android:textColor="#FFFFFF"
android:shadowColor="#BB0000"
android:shadowRadius="2.75" />
</LinearLayout>
</LinearLayout>
最佳答案
可能与每个 TextView
上的这段代码有关:
android:shadowColor="#BB0000"
android:shadowRadius="2.75"
如果您不想要红色阴影,则可能需要将其移除。
关于安卓自定义toast : TextColor set to black but has red shadow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14926625/