【问题标题】:Android custom notification backgroundAndroid自定义通知背景
【发布时间】:2018-02-05 10:28:47
【问题描述】:

我的布局根目录中有一个带有 RelativeLayout 的自定义通知。我需要将背景图像设置为此RelativeLayout。我有一个图片网址,然后我使用毕加索下载位图。 有没有办法将位图设置为自定义通知?

所有答案都是关于位于资源remoteView.setInt(R.id.viewid, "setBackgroundResource", R.color.your_color) 中的设置颜色或图像。

【问题讨论】:

  • 你用过这个方法吗? setImageViewBitmap(int viewId, Bitmap bitmap)
  • 问题是viewId不是imageView,而是RelativeLayout

标签: android notifications custom-notification


【解决方案1】:

很遗憾,我无法为 RelativeLayout 添加背景,但我找到了一种解决方法。我做了这样的布局

<FrameLayout>
    <ImageView android:layout_width="match_parent"
               android:layout_height="match_parent"/>
    <RelativeLayout android:layout_width="match_parent"
               android:layout_height="match_parent"/>
</FrameLayout>

ImageView 现在可以作为背景,因为它在 FrameLayout 中首先出现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-20
    • 2012-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多