I want to have a TextView with the marquee effect in my RemoteView
I have this layout XML describing the layout of my RemoteView (R.layout.notification_loading_small):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="64dip"
android:background="@color/primary_background_inverted">
<ProgressBar android:indeterminate="true"
android:layout_width="64dip"
android:layout_height="64dip"
android:id="@+id/marker_progress" style="?android:attr/progressBarStyle"
android:layout_gravity="center_vertical|center_horizontal"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical"
android:padding="@dimen/padding_small"
android:gravity="center_vertical">
<TextView
android:id="@+id/notification_small_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/primary_textcolor_inverted"
android:textSize="@dimen/text_size_large"
android:text="@string/loading"/>
<TextView
android:id="@+id/notification_small_textview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/secondary_textcolor_inverted"
android:textSize="@dimen/text_size_small"
android:text="@string/loading_advice"/>
</LinearLayout>
</LinearLayout>
And a method in my Java like this:
public void createTestNotification() {
mSmallLoadingNotificationView = new RemoteViews(getPackageName(), R.layout.notification_loading_small);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
PlayerService.this)
.setSmallIcon(R.drawable.ic_notification).setContentTitle(APP_NAME)
.setOngoing(true).setPriority(NotificationCompat.PRIORITY_MAX)
.setContent(mSmallLoadingNotificationView);
mNotification = builder.build();
startForeground(PLAYERSERVICE_NOTIFICATION_ID, mNotification);
}
I want to make the text in id/notification_small_textview2 to marquee horizontally, but it seems like an impossible task so far...
According to the Internet I need to add android:ellipsize="marquee", android:marqueeRepeatLimit="marquee_forever", android:lines="1" and android:singleLine="true" in my TextView. It also seems that we need to call the method setSelected(true) from the TextView in Java. However I cannot find a way to do this in that method... What am I missing?
How should I modify my Java code in order for the marquee to work?