Android's Toast default colors and alpha

∥☆過路亽.° 提交于 2019-12-10 13:17:35

问题


What are the default colors of the Toast component - the inner dark gray color, light gray border color and the value of alpha? I double checked the source of Toast.java but couldn't find it.


回答1:


So from the transient_notification layout xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:background="@drawable/toast_frame">

  <TextView
    android:id="@android:id/message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textAppearance="@style/TextAppearance.Small"
    android:textColor="@color/bright_foreground_dark"
    android:shadowColor="#BB000000"
    android:shadowRadius="2.75"
    />

</LinearLayout>

Which points to the res/drawable-hdpi/toast_frame.9.png. That image seems to vary from version to version though. You can find these in your android-sdk folder, inside /platforms/<the version you want>/data/res.




回答2:


As I found Default Toast Color and Alpha are as below

Color - black (0, 0, 0)

Alpha - 150

ARGB - (150, 0, 0, 0)

You can use the below java code to make a Toast Rectangular:-

Toast_obj.getView().setBackgroundColor(Color.argb(150, 0, 0, 0));


来源:https://stackoverflow.com/questions/8262769/androids-toast-default-colors-and-alpha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!