I have an Activity that serves as a music player. When it starts, the MediaPlayer object is initialized and launched. In the layout, I have TextViews to display the artist and title. These values ββ(retrieved from the server) can be long, so I added
android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true"
to scroll through the text. There is a strange problem: when I click the pause button, TextViews scrolls, but they donβt scroll while playing music. Any ideas?
PS I update SeekBar every 500 ms using Runnable , can there be a problem with this?
Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:gravity="center_vertical" tools:context=".MainActivity" > <LinearLayout android:id="@+id/main_header" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentTop="true" android:orientation="horizontal" > </LinearLayout> <ImageView android:id="@+id/imgCoverArt" android:layout_width="150dp" android:layout_height="150dp" android:layout_below="@+id/main_header" android:layout_centerHorizontal="true" android:layout_marginBottom="15dp" android:layout_marginTop="20dp" android:src="@drawable/cover_default" /> <SeekBar android:id="@+id/seekBarMain" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/imgCoverArt" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="10dp" android:paddingLeft="9dp" android:paddingRight="9dp" android:progressDrawable="@drawable/pb" android:thumb="@drawable/pbhead" /> <TextView android:id="@+id/tvArtist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/seekBarMain" android:layout_centerHorizontal="true" android:layout_marginTop="35dp" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:text="Large Text" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#FFFFFF" /> <TextView android:id="@+id/tvTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/tvArtist" android:layout_centerHorizontal="true" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#FFFFFF" /> <TextView android:id="@+id/tvTimeElapsed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/seekBarMain" android:layout_alignLeft="@+id/seekBarMain" android:layout_marginBottom="-10dp" android:text="02:54" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> <TextView android:id="@+id/tvTotalTime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/seekBarMain" android:layout_alignRight="@+id/seekBarMain" android:layout_marginBottom="-10dp" android:text="05:45" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#FFFFFF" /> <LinearLayout android:id="@+id/LinearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:gravity="center_horizontal" android:orientation="horizontal" > <Button android:id="@+id/btnPrevious" android:layout_width="100dp" android:layout_height="40dp" android:layout_gravity="center_vertical" android:layout_marginRight="6dp" android:background="@drawable/prev_btn_state" /> <Button android:id="@+id/btnPlay" android:layout_width="80dp" android:layout_height="80dp" android:layout_gravity="center_vertical" android:background="@drawable/button_play" /> <Button android:id="@+id/btnNext" android:layout_width="100dp" android:layout_height="40dp" android:layout_gravity="center_vertical" android:layout_marginLeft="3dp" android:background="@drawable/next_btn_state" /> </LinearLayout> </RelativeLayout>
Droidman
source share