0

Ich habe eine eigene Implementierung der Marquee-Klasse, da der Benutzer das Laufschrift Verhalten (kein Bildlauf, Bildlauf, Bildlauf) für den Text in meiner Musik-App entscheiden kann. Das Problem tritt auf, wenn der Benutzer beginnt, die Songs abzuspielen, da er im Layout ständig timer text (id: tv_playtime) aktualisiert.benutzerdefinierte Klasse Laufschrift Text neu gestartet, während eine andere Textansicht in einem komplexen Layout ändern

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
    android:id="@+id/main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     > 
     <RelativeLayout 

      android:layout_width="48dp" 
      android:layout_height="48dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:clickable="true" 
      android:onClick="onButtonHomeClick"> 
      <ImageView 

       android:layout_width="48dp" 
       android:layout_height="48dp" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       /> 
      <ImageView 

       android:layout_width="64.67dp" 
       android:layout_height="25.33dp" 
       android:layout_alignParentTop="true" 
       android:layout_marginLeft="2dp" 

       android:background="@null" 
       android:duplicateParentState="true" 
       android:scaleType="fitStart" 

       android:visibility="gone" /> 
     </RelativeLayout> 
     <!--home buttons--> 
     <TextView 

      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:text="Media Player" 
      android:textColor="@color/white" 
      android:textSize="20dp" /> 
     <ImageView 
      android:id="@+id/iv_settings_btn_passenger" 
      android:layout_width="48dp" 
      android:layout_height="48dp" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 
      /> 
    </RelativeLayout> 
    <!--media player home--> 
    <RelativeLayout 

     android:layout_width="wrap_content" 
     android:layout_height="36dp" 
     > 
     <ImageView 

      android:layout_width="36dp" 
      android:layout_height="36dp" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 

      android:tint="@color/white" 
      android:visibility="invisible" /> 
     <ImageView 

      android:layout_width="36dp" 
      android:layout_height="36dp" 

      /> 
     <ImageView 

      android:layout_width="36dp" 
      android:layout_height="36dp" 

      /> 
     <ImageView 

      android:layout_width="36dp" 
      android:layout_height="36dp" 

      /> 
    </RelativeLayout> 
    <!-- playing indicator--> 
    <RelativeLayout 

     android:layout_width="match_parent" 
     android:layout_height="370dp" 
      > 
     <RelativeLayout 

      android:layout_width="240dp" 
      android:layout_height="240dp" 
      android:layout_centerInParent="true" 
      android:layout_alignParentTop="true"> 
      <ImageView 

       android:layout_width="240dp" 
       android:layout_height="240dp" 
      /> 
     </RelativeLayout> 
     <RelativeLayout 

      android:layout_width="wrap_content" 
      android:layout_height="130dp" 

      android:layout_marginTop="5dp"> 
      <ImageView 

       android:layout_width="30dp" 
       android:layout_height="30dp" 

       android:visibility="gone"/> 
      <ImageView 

       android:layout_width="30dp" 
       android:layout_height="24dp" 


       android:visibility="gone"/> 
      <ImageView 

       android:layout_width="30dp" 
       android:layout_height="24dp" 


       android:visibility="gone"/> 
      <myClass.MarqueeTextView 
       android:id="@+id/marqueetext1" 
       android:layout_width="match_parent" 
       android:layout_height="30dp" 
       android:layout_centerInParent="true" 
       android:layout_marginLeft="60dp" 
       android:layout_marginRight="60dp" 
       android:clickable="true" 
       android:ellipsize="marquee" 
       android:focusable="true" 
       android:marqueeRepeatLimit="0" 
       android:scrollHorizontally="true" 
       android:singleLine="true" 
       android:text="Song Name" 
       android:textColor="@android:color/white" 
       android:textSize="24dp" /> 
      <myClass.MarqueeTextView 
       android:id="@id/marqueetext2" 
       android:layout_width="match_parent" 
       android:layout_height="20dp" 
       android:layout_below="@+id/marqueetext1" 
       android:layout_centerInParent="true" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="60dp" 
       android:layout_marginRight="60dp" 
       android:clickable="true" 
       android:ellipsize="marquee" 
       android:focusable="true" 
       android:marqueeRepeatLimit="0" 
       android:scrollHorizontally="true" 
       android:singleLine="true" 
       android:text="Artist Name" 
       android:textColor="@android:color/white" 
       android:textSize="18dp" /> 
      <myClass.MarqueeTextView 
       android:id="@id/marqueetext3" 
       android:layout_width="150dp" 
       android:layout_height="20dp" 
       android:layout_alignParentBottom="true" 
       android:layout_below="@+id/marqueetext2" 
       android:layout_marginLeft="60dp" 
       android:layout_marginTop="8dp" 
       android:clickable="true" 
       android:ellipsize="marquee" 
       android:focusable="true" 
       android:marqueeRepeatLimit="0" 
       android:scrollHorizontally="true" 
       android:singleLine="true" 
       android:text="Album Name" 
       android:textColor="@color/white" 
       android:textSize="18dp"/> 
      <TextView 
       android:id="@+id/tv_playtime" 
       android:layout_width="wrap_content" 
       android:layout_height="20dp" 
       android:layout_alignParentRight="true" 
       android:layout_below="@+id/marqueetext2" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="8dp" 
       android:text="00.00" 
       android:textColor="@color/white" 
       android:textSize="18dp" /> 
     </RelativeLayout> 
    </RelativeLayout> 
    <!--media player tracks--> 
    <RelativeLayout 

     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="70dip" 
     android:visibility="gone"> 
     <ImageView 

      android:layout_width="30dip" 
      android:layout_height="30dip" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_marginLeft="14dip" 
      /> 
     <myClass.MarqueeTextView 

      android:layout_width="match_parent" 
      android:layout_height="30dip" 
      android:layout_alignParentBottom="true" 
      android:layout_marginLeft="14dip" 
      android:layout_marginRight="5dip" 
      android:ellipsize="marquee" 
      android:marqueeRepeatLimit="0" 
      android:scrollHorizontally="true" 
      android:singleLine="true" 
      android:textSize="20sp" 
      android:textStyle="bold" /> 
    </RelativeLayout> 
    <!--mood--> 
    <myClass.GestureView 

     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 
    <!--gestures--> 
    <RelativeLayout 

     android:layout_width="match_parent" 
     android:layout_height="44dp" 
     android:layout_alignParentBottom="true" 
     > 
     <RelativeLayout 

      android:layout_width="match_parent" 
      android:layout_height="16dp"> 
     </RelativeLayout> 
     <RelativeLayout 

      android:layout_width="match_parent" 
      android:layout_height="28dp" 
      android:layout_alignParentBottom="true" 

      > 
      <RelativeLayout 

       android:layout_width="match_parent" 
       android:layout_height="28dp"> 
       <TextView 

        android:layout_width="wrap_content" 
        android:layout_height="20dp" 
        android:layout_alignParentRight="true" 
        android:layout_marginLeft="50dp" 
        android:layout_marginRight="20dp" 
        android:text="00:00" 
        android:textColor="@android:color/white" 
        android:textSize="18dp" 
        android:visibility="gone" /> 
       <TextView 

        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_marginRight="7dip" 
        android:text="03:50" 
        android:textColor="@android:color/white" 
        android:textSize="14dp" 
        android:textStyle="bold" 
        android:visibility="gone" /> 
       <SeekBar 

        style="@style/seekBarMyStyle" 
        android:layout_width="match_parent" 
        android:layout_height="16dp" 
        android:layout_alignParentBottom="true" 
        android:layout_marginLeft="30dp" 
        android:layout_marginRight="30dp" 
        android:maxHeight="2dp" 
        android:minHeight="2dp" 
        android:visibility="visible" /> 
      </RelativeLayout> 
     </RelativeLayout> 

    </RelativeLayout> 
    <RelativeLayout 

     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:visibility="gone"> 
     <RelativeLayout 

      android:layout_width="match_parent" 
      android:layout_height="26dip" 
      android:layout_alignParentTop="true"> 
      <TextView 

       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:shadowColor="@color/text_shadow_color" 
       android:shadowDx="2.5" 
       android:shadowDy="2.5" 
       android:shadowRadius="0.01" 
       android:text="06:18" 
       android:textColor="@color/white" 
       android:textSize="15sp" 
       android:textStyle="bold" /> 
      <ImageView 

       android:layout_width="26dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 
       /> 
      <ImageView 

       android:layout_width="26dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 
       android:layout_toLeftOf="@id/iv_mp_battery" 

       android:visibility="gone" /> 
      <ImageView 

       android:layout_width="26dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 


       android:visibility="gone" /> 
      <ImageView 

       android:layout_width="26dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 

       /> 
      <ImageView 
       android:layout_width="86dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 
       android:layout_toLeftOf="@id/iv_mp_signal" 
       /> 
      <ImageView 

       android:layout_width="86dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 

       /> 
      <ImageView 

       android:layout_width="86dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 

       /> 
      <ImageView 

       android:layout_width="86dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 

       /> 
      <ImageView 

       android:layout_width="86dip" 
       android:layout_height="match_parent" 
       android:layout_centerVertical="true" 

       /> 
     </RelativeLayout> 

    </RelativeLayout> 
    </RelativeLayout> 
    <LinearLayout 
    android:background="@color/darkbackgroundcoloralpha" 

    android:layout_width="match_parent" 
    android:layout_height="176dp" 
    android:layout_marginTop="50dp" 
    android:orientation="vertical" 
    android:visibility="gone" /> 
</FrameLayout> 

Ich mag hier das Scroll-Verhalten von marqueetext1 steuern, was in Ordnung arbeitet, wenn der Song angehalten wird (Da Timer Textfeld wird nicht aktualisiert).

Ich habe ähnliche Probleme versucht, aber keiner von ihnen für mich

Hinweis arbeiten: Bin gestu mit res für Media-Player-Steuerung (Next, Previous, Play, Pause)

Meine Annahme ist, dass es wegen des Layouts geschieht, da ich ein Debugging in benutzerdefinierten Marquee-Klasse durchgeführt habe, deren Eigenschaften den Marquee-Neustart hier nicht beeinflussen. Ich habe OnFocusChanged, OnWindowFocusChanged und IsFocused-Methoden in meiner abgeleiteten Marquee-Klasse überschreiben, um die Textansicht alle fokussiert zu machen. Was fehlt hier?

Antwort

0

Mein Timer überlappte sich in Laufschrifttextfeldern; Die Begrenzung der Breite der Timer-Textansicht löste das Problem.

<TextView 
       android:id="@+id/tv_playtime" 
       android:layout_width="50dp" 
       android:layout_height="20dp" 
       android:layout_alignParentRight="true" 
       android:layout_below="@+id/marqueetext2" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="8dp" 
       android:text="00.00" 
       android:textColor="@color/white" 
       android:textSize="18dp" /> 
Verwandte Themen