Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android notification Marquee not working

Tags:

android

In my app there is a custom notification, with the following layout. My problem is that the marquee doesn't working. plz help me. Thanks in advance

> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/notification_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp" >

    <ImageView
        android:id="@+id/notification_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dp"
        android:background="@drawable/icon" />

    <TextView
        android:id="@+id/notification_title"
        style="@style/NotificationTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/notification_image"
        android:text="asaadsadad" />

    <TextView
        android:id="@+id/notification_message"
        style="@style/NotificationText"
        android:layout_width="wrap_content"
        android:ellipsize="marquee"
        android:lines="1"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_height="wrap_content"
        android:layout_below="@+id/notification_title"
        android:layout_toRightOf="@+id/notification_image"
        android:text="@string/four_day_delay_msg"
        android:focusable="true" />

</RelativeLayout>

Can add scroll in notification??

like image 530
jibysthomas Avatar asked Apr 02 '26 03:04

jibysthomas


1 Answers

Well, I've spent quite a bit of time researching this and I think it's safe to say there are some major hurdles to overcome in order to accomplish this. It's worth noting that there are some examples of Google Apps using marquee in their custom notifications, however it's in their HoneyComb Android 4.0 release, so perhaps they fixed the issues I'm about to address. Also I haven't seen marquee implemented in Google Apps like Google Music which should marquee long song names or artists.

I love numbered lists...

  1. The problem with marquee. It's a finicky setting, not only do you have to set ellipsis to marque you have to make sure the view in which it is contained gains focus, otherwise it will never marquee. So naturally my first attempt to was try and focus on the textview after the notification was created. Android didn't like that, on to #2.
  2. Then I went ahead and researched autoScrolling Marquee TextViews. I thought I had it this time, unfortunately not. Some real smart people decided they didn't like the limitations of marquee so instead they created a custom component that autofocuses itself. So the marquee will always operate. But then when I added it to the custom notifications Android again said nay. I guess custom notifications don't like having custom components, I even tried creating a custom RelativeLayout to focus on the textview when onFinishInflate() was called.
  3. There is so more research you could do, that I just gave up on. Either look up how to use custom components in a custom notification. I looked, for 15 minutes at least, no luck. Or look up how to focus an item in a custom notification, seems even more odd. Both of my searches yielded no results, but there weren't a lot of StackOverflow questions about such things. Might yield some luck posting a new question here.

Resources...

Custom Component - AutoScrolling Marquee TextView - http://androidbears.stellarpc.net/?p=185

Custom Component - Relative Layout onFinishInflate() - Android : how to create custom component - http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TwoLineListItem.java.shtml

Google App with example of Marquee in custom notification (TextView titled: notification_title) - http://developer.android.com/resources/samples/HoneycombGallery/res/layout/notification.html

like image 120
Rawr Avatar answered Apr 08 '26 05:04

Rawr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!