Custom marquee notification text does not work.

Hi, I'm trying to make part of my text in the notification highlighting area, but it doesn't work. I tried this:

<TextView android:id="@+id/title_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="bottom" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:textSize="15sp" android:textStyle="bold" > </TextView> 

and in my .java I use remoteview:

 Notification notification = new Notification(icon, tickerText, when); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification); contentView.setTextViewText(R.id.title_text, "This is a very long text which is not fitting in the screen so it needs to be marqueed"); 

I would like to have a selection for this title_text. This is a very long text that does not fit on the screen, so it should be marked

but the tent does not work, remains motionless, what can I do?

thanks.

+4
source share
3 answers

i changed my xml:

  <TextView android:id="@+id/title_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="bottom" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="false" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:textSize="15sp" android:textStyle="bold" android:textColor="#fff"> <requestFocus/> </TextView> 

I added <requestFocus/> , and now my area is working fine.

+10
source

According to docs, setting the scrollHorizontally attribute to true will not wrap the text around the edge. Try setting false to use the ellipsize attribute.

+1
source

I lost a day to understand that this effect is performed using this method from NotificationCompat.Builder : setTicker , which support RemoteView

I really hope the answer saves a lot of lives :) (almost lost my hair)

0
source

Source: https://habr.com/ru/post/1440980/


All Articles