Java 如何在我的定制土司中也能得到土司的浅蓝色光环?

Java 如何在我的定制土司中也能得到土司的浅蓝色光环?,java,android,android-layout,toast,Java,Android,Android Layout,Toast,我创建自定义toast主要是因为我将其放置在网格视图上,并且需要对其宽度进行一些控制。但是我真的很喜欢标准吐司上的浅蓝色光环,我想把它拿回来(或者至少让我的定制吐司看起来有点像默认吐司) 实现这一目标的简单/优雅方式是什么 我根据此布局创建了一个自定义toast: <LinearLayout android:id="@+id/toast_layout_root" android:layout_width="fill_parent"

我创建自定义toast主要是因为我将其放置在网格视图上,并且需要对其宽度进行一些控制。但是我真的很喜欢标准吐司上的浅蓝色光环,我想把它拿回来(或者至少让我的定制吐司看起来有点像默认吐司)

实现这一目标的简单/优雅方式是什么

我根据此布局创建了一个自定义toast:

    <LinearLayout 
        android:id="@+id/toast_layout_root"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:padding="10dp">
        <ImageView android:id="@+id/toast_layout_image" 
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:src="@drawable/icon" android:layout_marginRight="10dp">
        </ImageView>
        <TextView android:layout_width="wrap_content" 
            android:layout_height="wrap_content" android:id="@+id/toast_layout_text"           
            android:textColor="#FFF" android:textAppearance="?android:attr/textAppearanceLarge">
        </TextView>
    </LinearLayout>

这看起来非常干净,但与默认的toast完全不同

为您的toast邮件应用此布局:

<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:padding="35dp"
        android:orientation="horizontal" 
        android:background="@android:drawable/dialog_holo_dark_frame" >
        <ImageView android:id="@+id/toast_layout_image" 
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:src="@drawable/appicon" android:layout_marginRight="10dp">
        </ImageView>
        <TextView android:layout_width="wrap_content" 
            android:layout_height="wrap_content" android:id="@+id/toast_layout_text"           
            android:textColor="#FFF" android:textAppearance="?android:attr/textAppearanceLarge">
        </TextView>
    </LinearLayout>

我没有找到什么是cellWidth和cellHeight,所以如果填充物不合适,请尝试使用填充物

编辑:哦,我应用了深色主题,尝试使用浅色

对背景的正确引用是“@android:drawable/toast_frame”(这里有一个很好的所有android drawable列表:)
<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:padding="35dp"
        android:orientation="horizontal" 
        android:background="@android:drawable/dialog_holo_dark_frame" >
        <ImageView android:id="@+id/toast_layout_image" 
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:src="@drawable/appicon" android:layout_marginRight="10dp">
        </ImageView>
        <TextView android:layout_width="wrap_content" 
            android:layout_height="wrap_content" android:id="@+id/toast_layout_text"           
            android:textColor="#FFF" android:textAppearance="?android:attr/textAppearanceLarge">
        </TextView>
    </LinearLayout>