小编Man*_*our的帖子

Android Lollipop中的通知背景为白色.我该怎么改变它?

我想在我的应用中显示消息通知.在以前的Android版本中,一切都很好,但在Lollipop中,通知背景是白色的.我将此XML代码用于我的通知布局layout_message_notification.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_messageNotification"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight=".2"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:src="@drawable/message_icon"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight=".8"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent">

        <TextView
            android:id="@+id/textView_notification_title"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="right|center_vertical"
            android:layout_margin="15dp"/>

    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我在棒棒糖中的通知显示如下: 棒棒糖的通知方式

如何将通知背景设置为暗或透明,就像以前的Android版本一样?

notifications android background transparent android-5.0-lollipop

13
推荐指数
2
解决办法
1万
查看次数