0

У меня есть собственная реализация класса marquee, так как пользователь может выбрать поведение шатра (без прокрутки, прокрутки один раз, повторение прокрутки) для текста в моем музыкальном приложении. Проблема возникает всякий раз, когда пользователь начинает воспроизводить песни, так как он постоянно обновляет текст таймера (id: tv_playtime) в макете.текст настраиваемого класса marquee перезапускается при смене другого текстового вида в сложном макете

<?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> 

Я хочу, чтобы управлять прокрутку поведением marqueetext1 здесь, которая работает хорошо, когда песня паузы (С текстом таймера поле не обновляется).

Я пробовал подобные проблемы, но ни один из них не работает для меня

Примечание: Я использую gestu res для управления медиаплеером (Next, previous, play, pause)

Мое предположение происходит из-за макета, так как я выполнил сквозную отладку в пользовательском классе Marquee, свойства которого не влияют на перезапуск marquee. Я переопределяю onFocusChanged, onWindowFocusChanged и isFocused методы в моем классе Marquee, чтобы сделать Textview все сфокусированным. Что здесь отсутствует?

ответ

0

Мой таймер был перекрыт текстовыми полями marquee; поэтому ограничение ширины таймерного текста разрешило проблему.

<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" /> 
Смежные вопросы