【发布时间】:2015-03-26 00:12:05
【问题描述】:
我想在我的应用中显示消息通知。在以前的 Android 版本中一切正常,但在 Lollipop 中,通知背景是白色的。
我在layout_message_notification.xml 中将此 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>
我在棒棒糖中的通知显示如下:
如何使通知背景变暗或透明,就像以前的 Android 版本一样?
【问题讨论】:
标签: android background notifications android-5.0-lollipop transparent