<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Darshan Pania on Medium]]></title>
        <description><![CDATA[Stories by Darshan Pania on Medium]]></description>
        <link>https://medium.com/@DarshanCT?source=rss-fe4968aaf9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IkdoN30Qc7725Spno99x8Q.jpeg</url>
            <title>Stories by Darshan Pania on Medium</title>
            <link>https://medium.com/@DarshanCT?source=rss-fe4968aaf9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:32:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DarshanCT/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Custom Layouts for your Push Notification]]></title>
            <link>https://medium.com/android-news/custom-layouts-for-your-push-notification-d8219d9962e?source=rss-fe4968aaf9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8219d9962e</guid>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Darshan Pania]]></dc:creator>
            <pubDate>Mon, 03 Jul 2017 06:48:49 GMT</pubDate>
            <atom:updated>2017-10-30T07:55:28.054Z</atom:updated>
            <content:encoded><![CDATA[<h4>powered by</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*hNFUClbLsueLd2gPwqudEA.png" /></figure><p>As you know the Android framework is open source and hence provides a lot of flexibility regarding each and every aspect of your app. Many mobile companies like Xiaomi, OnePlus and Samsung provide their mobile OS which is built on top of the stock Android OS. The flexibility is such that you can customise the look and feel of your app at the very minute detail, right from icons used to display as a widget on your phone’s screen to the push notifications which appear in your phone’s system tray.</p><p>In this article, we will be discussing how to render your own layout for a push notification. By default, a push notification from an app looks like this -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*y2iC4tV3FSChNuvubqfCiQ.png" /><figcaption>Default Push Notification</figcaption></figure><p>These notifications are very common and most of the notifications look pretty much the same. So if you want your app’s push notification to stand out for the user, how will you do it?</p><p>Android has the answer for you in it’s scarcely used class <a href="https://developer.android.com/reference/android/widget/RemoteViews.html">RemoteViews</a>. Using RemoteViews, you can inflate pretty much any layout of your choice. Before we start with an example, an Android push notification has two styles. When the notification appears in the system it is in the normal style i.e, you cannot view the image attached to it (if there is one) and the other is the BigPicture style which renders the image as well. Android provides the capability to customise both these styles. Let’s start with the example now -</p><h4>Pre-requisite</h4><p>In this example, we are considering that your app is already integrated with CleverTap. If you have not, then visit <a href="https://clevertap.com/">CleverTap</a> and integrate your app following their in-depth <a href="https://support.clevertap.com/docs/android/getting-started.html">documentation</a>. Also we are considering you are using <a href="https://firebase.google.com/docs/cloud-messaging/">FCM</a> to register your app with Google to receive push notifications.</p><h4>Layouts</h4><p>We will start with creating the XML files for the two kinds of styles in which an Android push notification displays, the normal style and BigPicture style. Currently the Android OS only allows TextViews and ImageViews to be shown in a Push notification. Create the following two XML files in your <strong><em>layout</em></strong> folder under <strong><em>res</em></strong> folder of your project.</p><h4>custom_notification.xml</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bba3fbe21e7d9f1106f53a3d017c5aa/href">https://medium.com/media/6bba3fbe21e7d9f1106f53a3d017c5aa/href</a></iframe><h4>custom_notification_small.xml</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29525c8e72162d156f83149d25e3aa4d/href">https://medium.com/media/29525c8e72162d156f83149d25e3aa4d/href</a></iframe><h4>Code to render these layouts</h4><p>We are assuming that you have integrate FCM, if so you will have a class extending FirebaseMessagingService. The key values used in this code snippet is just for example, you can set any key of your choice.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbd99fba39debcc2636a0aa491a43b93/href">https://medium.com/media/fbd99fba39debcc2636a0aa491a43b93/href</a></iframe><h4>CleverTap Dashboard</h4><p>On the CleverTap Dashboard, while creating a push notification, enter the Title and Message as it is mandatory and click on “Advanced” checkbox and then click “Add pair” under Custom Key-Value Pairs. Fill in the key value pairs as per your requirements. Click on “Send a test notification” and send a push notification to your FCM token and make sure it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtd_IKAOsO53ez3xnWAqvQ.png" /><figcaption>CleverTap Dashboard</figcaption></figure><h4>Power in your hands</h4><p>So with this example, you can design fancy eye catching push notifications for your users. Pretty much everything is customisable, you can change the text colour, text size, text appearance and text placement too. The same goes with the images as well. You can have any number of images, you can keep them in your drawable or you can download it from a link the way it has been done in the above example code. The BigPicture style lets you have another proper image to be rendered. The height and width of the big picture can be customised. Any kind of image can be used, but it is advisable to use “.png” images in your drawable folder. If you are downloading the image from a URL then there are no such restrictions. The background colour of the push notification can be changed from the default white to any colour of your choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*R9dwbqZlQHtFxmE9_XXHZQ.png" /><figcaption>This is how your notification will look in the Normal style</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*PbafRNK-OQ_usuSu860wZQ.png" /><figcaption>This is how your notification will look in the Big style</figcaption></figure><p>The permutations and combinations are several and it is upto your creativity to make use of this feature provided by Android to the best of your app’s strength.</p><p>If you found this article of some help, please do comment and share it!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8219d9962e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/custom-layouts-for-your-push-notification-d8219d9962e">Custom Layouts for your Push Notification</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>