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.
Asked
Active
Viewed 7,400 times
2 Answers
17
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
.

dmon
- 30,048
- 8
- 87
- 96
-
How did you find this? Do you know perhaps where to find the position it gets put on the screen, too? – android developer Dec 08 '20 at 00:07
1
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));

lRadha
- 641
- 6
- 16