androidnotificationscustom-notification

Android custom notification background


I have a custom notification with RelativeLayout in root of my layout. I need to set background image to this RelativeLayout. I have an image url and then I download Bitmap using Picasso. Is there a way to set Bitmap to custom notification?

All answers are about settings color or image which are located in resources remoteView.setInt(R.id.viewid, "setBackgroundResource", R.color.your_color).


Solution

  • Unfortunately, I couldn't add background to RelativeLayout, but I found a workaround. I made layout like this

    <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 now works as background because it goes first in FrameLayout.