如何制作自定义Toast消息以占据整个屏幕

Luk*_*kap 3 layout customization android toast android-layout

我为自定义Toast消息创建了布局,并将fill_parent设置为自定义布局的根元素,但布局的大小仍然比整个屏幕小很多.

是否可以设置toast消息的大小以占据整个屏幕?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/toast_layout_root"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" android:gravity="center" >
    <ImageView android:id="@+id/image"
               android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_margin="10dip"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

注意android:layout_width ="fill_parent"和android:layout_height ="fill_parent"属性.但我的布局仍然是屏幕的三分之一左右...

任何想法或建议如何让整个屏幕上的祝酒?

San*_*ndy 5

toast.setGravity(Gravity.FILL_HORIZONTAL|Gravity.FILL_VERTICAL, 0, 0);
Run Code Online (Sandbox Code Playgroud)