【问题标题】:Android custom toast: TextColor set to black but has red shadowAndroid自定义吐司:TextColor设置为黑色但有红色阴影
【发布时间】:2013-02-18 06:09:31
【问题描述】:

我对自定义 toast 有一点问题:toast 本身和三个 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>

【问题讨论】:

    标签: android toast


    【解决方案1】:

    可能与每个TextViews 上的这段代码有关:

    android:shadowColor="#BB0000"
    android:shadowRadius="2.75"
    

    如果您不想要红色阴影,您可能想要删除它。

    【讨论】:

    • 遗憾的是我有这个 - 但在 lib 而不是我在手机上测试并复制到这里的代码。经典的人为错误,已经很晚了,我一边看电视一边编码:/
    • @MarkusProske 这发生在我们最优秀的人身上——我已经说了很多次“我知道这不是”,然后就是这样。不用担心。 :)
    猜你喜欢
    • 2015-07-14
    • 1970-01-01
    • 1970-01-01
    • 2022-07-29
    • 2021-03-27
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多