I want to change default android notification view. Can I make height of Custom Expanded View more than 3 lines of text?
Check this article on how to make custom notifications using your own layout. If this helps you already: good. If not: The RemoteView also offers options to create custom notifications, so it might help you. Alternatively you could create multiple notifications if the number of lines is really limited (which I am not sure of).
Related
I read that we can add buttons to the Big view of notifications that is available from 4.1. I want the same layout with buttons in 4.0. I want to know if I use custom view for notification containing the buttons, Will that work in 4.0 ?
Thanks.
The notifications before 4.1 were limited which is why Big View notifications were introduced in 4.1
It isn't possible to have custom views before 4.1 unfortunately
One of the reasons for this is the height of the notification, its is limited so it doesn't fill up the screen.
I have managed to create this kind of notifications
following this guide: http://developer.android.com/training/notify-user/expanded.html#big-view
However I cannot find any documentation on how to achieve this style:
How can I do this?
As described in Custom notification layouts, you can set a custom content of the notification with Notification.Builder.setContent(RemoteViews)
You need to add custom notification layout and through the remote views.
http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification
https://stackoverflow.com/a/18414768/713778
The expanded notifications introduced in Jelly Bean allows adding actions. The actions appear as buttons in a row. If I wanted to modify this with my own custom view I would consider a remoteview.
Do expanded notifications allow for remoteviews? I can only find examples of remoteviews being used in simple notifications before the expanded notifications existed.
It appears that http://codeversed.com/expandable-notifications-android/ has the answer in the Custom View at the end.
So what if the rich notification styles don’t provide you with the
layout you need? Easy, just create your own layout and pass it to the
builder. One little fact to retain is that notifications use remote
views, which means you need to create a layout using a RemoteView.
Below is exactly how you would need to create this custom RemoteView.
notification.bigContentView = expandedView;
I'm trying to create a custom notification layout that looks just like a 3.0 notification, with a couple of extra things sprinkled in. More importantly, I also want to derive a Jelly Bean expanded notification on top of that.
I'd like the notification to have the same layout as a stock notification so it fits in nicely, i.e. like this (bottom image):
However, I cannot find any information about the proper dimensions and styles - what size do I need to use for the image on the left? What style for each text? What padding?
Ideally, I'd love to use something like android.R.listPreferredItemHeight for the height of the layout and the dimensions of the image, but I can't find anything that pertains to notifications.
You can use the Notification.Builder class which provides a convenient way to set the various fields of a Notification and generate content views using the platform's notification layout template.
See: http://developer.android.com/reference/android/app/Notification.Builder.html
If you need to be compatible with versions prior to API level 11 then take a look at the NotificationCompat.Builder from the support library.
As you can see in Android and OEM customisation, the items in Status Bar or Notification bar have different layouts.
The notification also differs depending on the Theme/Rom you installed.
Here is an example with Vanilla/Touchwizz/MIUI:
or or
What I would like to get is the layout, so I can include it in my activity and preview a notification inside my application.
I guess there is something similar to the android.R.layout.simple_list_item_1 for listview for instance.
Thank a lot for any help or any clue.
The layout for notification is located in separate SystemUI package: status_bar_latest_event (as of Android 2.3). This is not directly accessible from application. And if you could extract the layout, it wouldn't help you, as it uses custom com.android.systemui.statusbar.LatestItemView view. So you'd need to load that class into your process using PathClassLoader.
So theoretically this might be possible, but it's going to be tricky.