Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android's Toast default colors and alpha

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.

like image 768
Rafa de King Avatar asked Nov 24 '11 21:11

Rafa de King


2 Answers

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.

like image 54
dmon Avatar answered Nov 02 '22 14:11

dmon


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));
like image 1
lRadha Avatar answered Nov 02 '22 16:11

lRadha