Reputation: 65
I am using the following code to display the text stored in the array:
AppUtil.popMessage(this, "Streaming song: " + selectedSong.getTitle());
But the full text is not shown because of the limited space.
How do I add a marquee scrolling to the Action Bar?
Upvotes: 1
Views: 621
Reputation: 219
you need to create custom toolbar layout like bellow:
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/toolbar_color"
android:contentInsetEnd="0dp"
android:contentInsetLeft="0dp"
android:contentInsetRight="0dp"
android:contentInsetStart="0dp"
android:contentInsetStartWithNavigation="0dp"
android:gravity="left"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:layout_scrollFlags="enterAlways"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleTextColor="@android:color/white"
app:title="Title">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:gravity="left"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="title"
android:textSize="20dp"
android:singleLine="true"
android:maxLines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="@android:color/white"
android:gravity="center_vertical"
android:textStyle="bold"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
Upvotes: 1