【问题标题】:Android Notification icon on the left左侧的 Android 通知图标
【发布时间】:2014-06-08 04:46:02
【问题描述】:

这是一个奇怪的问题: 如何在导航抽屉中获取“样式化”通知图标?显然,Android(至少在我的 Nexus 5 上)为该图标添加了一点蓝色背景。我想获得带有背景的样式图标。

我真正想说的是: 我想使用 RemoteViews 制作一个很酷的自定义扩展通知。但是,我想在自定义 RemoteViews 通知的左上角保留默认样式的通知图标。

有什么想法吗?

【问题讨论】:

    标签: android notifications android-notifications remoteview


    【解决方案1】:

    啊,哈哈!明白了!

    https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/layout/notification_template_big_text.xml

    <ImageView
        android:id="@+id/notifcation_icon"
        android:layout_width="@dimen/notification_large_icon_width"
        android:layout_height="@dimen/notification_large_icon_height"
        android:background="@android:drawable/notification_template_icon_bg"
        android:scaleType="center" />
    

    顺便说一句,背景实际上只是 #3333B5E5,而这些尺寸只是 64dp。 请注意,这完全可以根据制造商、设备和 Android 版本进行更改。由于这些不是公共资源,因此最好的选择就是将其复制过来。不是很好,但必须这样做。

    我希望我对此的深入研究对某人有所帮助!

    【讨论】:

    • 如果有人在寻找通知中使用的平台文本样式,那就是 android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title"。感谢您的挖掘,真的很有帮助!
    猜你喜欢
    • 2016-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    相关资源
    最近更新 更多