How to use Notification.BigPictureStyle with long summary text? - android

I want to show notification with big picture(BigPictureStyle) and big text(BigTextStyle). How can I do it?

Setstyle only allows either BigPictureStyle or BigTextStyle. If you need a non-standard notification style, you may have to use a custom notification layout.
See Change Notification Layout and How to make an image fit a custom 256dp Big Picture Notification in Android? on using a custom notification layout. For multi-line long text use android:inputType="textMultiLine" for the TextView. The latter answer contains an example of custom big picture.

Related

Android notification: always expanded + rectangular

This weather app has an interesting notification type:
It's always expanded. Always.
There's no decoration/borders
It doesn't have rounded edges
Despite a lot of trying I failed to find out how to create such a notification. Does anybody know how it's called or could link to the relevant documentation or sample?
Here are 2 SO posts that may help you:
Is possible set Expanded Notification as default in Big Text Notifications?
Custom notification layout gives unnecessary margin
To set a notification as expanded in defualt you can do this
.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
to the notification
and for the next 2 queries you can implement a custom notification and then remove all the styles and add your own

Display HTML content in a Custom notification

Is it possible to build a custom notification that display HTML content ?
I saw that it's possible to build custom notification using RemoteViews, will it be possible to have WebView embedded in a RemoteViews, and pass it as a custom view to the notification ?
No, sadly this is impossible :(
Custom notifications can only contain RemoteViews which only can hold a certain subset of all views like Buttons, TextViews, etc.
Not sure if this is what you are asking for, but you should be able to style your notification with HTML tags, or add link to it. Here is the nice article on how to style notification with HTML: https://itnext.io/android-notification-styling-cc6b0bb86021
In short you should be able to do something like this:
val styleNotificationWithHtml = Html.fromHtml(yourNotification, FROM_HTML_MODE_LEGACY)

How to display Android push notification with no title/time on 3 lines

I have seen some apps for which push notifications only display the app icon on the left and the message content on the right, with no title nor time. Also the message content takes the entire space and can occupy up to 3 lines.
.
When I don't supply any title nor text, my message still appears below where the title and time should be. It can only occupy one line and ends up showing only the beginning, with some ellipsis at the end.
I already looked at BigView and BigTextStyle, but it doesn't look like it's what I want, as even if I don't supply a title nor time, the notification message doesn't move up. Also I don't want the user to have to expand the notification to see the whole text.
Is there any simple way to achieve what I want? Or do I have to create a custom layout? I'm using Phonegap and have very limited Android knowledge.
Here is the code I'm currently using: https://github.com/phonegap-build/PushPlugin/blob/master/src/android/com/plugin/gcm/GCMIntentService.java (see the createNotification method).
I wasn't able to find any easy way to do that, like tweaking existing objects. I guess it always requires creating a CustomNotification, which I did: I created a RemoteViews to display things exactly the way I wanted.

Dynamically change titlebar height in android

I'm using a custom titlebar created for my own use in the app i'm making, containing the title and some buttons. However occasionally I get titles that are slightly too long for the titlebar, where the titles are out of my control.
Currently setting the titlebar's height through "android:windowTitleSize="70dp"" in the titlebar's theme, but is there a way to dynamically change it if I can detect that the incoming title is too long and falls over into two lines?
I didn't find a solution for this either.. but you could try android:ellipsize="end".
This way if the text will flow out of the TextView's bounds, the text will be cut of at the end and "..." will be added to the text.
Here is also the documentation.

Scrolling body text on Android Notification

Is there a way to get the body text of a notification to scroll along the notification?
If this text is too long it just fades out at the border near the time. Is there a way to make it scroll slowly along so that someone could read it while in the notification drop down menu without having to either read it when it ticks along the status bar when it is received, but without going into the app?
I think this would be possible with a custom notification layout that housed XML with scrolling views, but i cannot use a custom layout, the notifications need to be created through the default notification creator.
Anyone know if this is possible?
Edit: im in no way affiliated with Onavo Lite, it was just a image i found to point out the text area i want to manipulate.
No, the default notification layout uses TextViews with a maximum size and no scrolling features.

Categories

Resources