安卓自定义toast : TextColor set to black but has red shadow

标签 android toast

我对自定义 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/

相关文章:

android - UIL图像显示在GridView中imageView的中心

android - 自定义 Toast 定位

android - AsyncTaskLoader 与 AsyncTask

android - 有什么方法可以将图标添加到 Snackbar?

ionic-framework - Toast 消息中的按钮处理程序 Ionic 4 未触发,为什么?

android - toast 和持续时间

java - 当我单击计算器应用程序中的算术函数按钮时,为什么我的应用程序会停止?

java - 当用户尝试插入超过最大限制的文本时如何制作 toast ?

android - Google Place API - 自动完成 - 如何获取邮政编码?

android - 如何在 Kivy 中重置小部件