2011-07-18 10 views
2

マーキー・アニメーションは機能しませんが、これは私が行ったことです。マーキー・テキスト・ビュー・アニメーション

<LinearLayout android:layout_height="wrap_content" 
      android:layout_width="wrap_content" android:background="@drawable/bg_trans" 
      android:layout_alignParentBottom="true" android:orientation="vertical"> 

      <TextView android:id="@+id/trackName" 
      android:layout_height="wrap_content" android:layout_width="wrap_content"     
      android:textColor="@android:color/white" android:textSize="18sp" 
      android:maxLines="2" android:ellipsize="marquee" 
      android:scrollHorizontally="true" 
      android:focusable="true" android:focusableInTouchMode="true" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:layout_gravity="center_horizontal" /> 

      <TextView android:id="@+id/artistName" 
      android:layout_height="wrap_content" android:layout_width="wrap_content"     
      android:textColor="@android:color/white" android:textSize="18sp" 
      android:maxLines="2" android:ellipsize="marquee" 
      android:scrollHorizontally="true" 
      android:focusable="true" android:focusableInTouchMode="true" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:layout_gravity="center_horizontal" /> 
      </LinearLayout> 

これは最初のテキストビューでは機能しますが、2番目のテキストビューでは機能しません。私は間違って何をしていますか?

答えて

8

これが私の作品 -

<TextView 
android:id="@+id/capture_mode" 
android:layout_width="200px" 
android:layout_height="wrap_content"   
android:text="This is a test of marquee on the text view in android." 
android:ellipsize="marquee" 
android:scrollHorizontally="true" 
android:singleLine="true" 
android:focusable="true" 
android:focusableInTouchMode="true" 
android:marqueeRepeatLimit="marquee_forever" 
/> 

フィールドmarqueeRepeatLimitがrepitionsの数を設定します。

更新:テキストビューの幅を特定の値にハードコードする必要がある場合は、wrap_contentに設定することができます。そのような場合、マーキーは、テキストの終わりの後に、テキストを再び表示する前に空白を持つように機能します。 (彼らは次の項目を表示する前の表示中に、いくつかのギャップを持っている、デジタル看板を考えてみてください。)

+0

を追加する私のために働い追加する必要があり、その後何の上に言及されているその他しかし、テキストは、それが動作するためにtextviewよりも大きくなければなりませんか? – Hades

+0

ええ、それ以外の場合は、私は全体を見ることができるので、テキストを動かしている点は表示されません:) – bluefalcon

+0

それはアニメーションと呼ばれている理由です。 – Hades

1

あなたも

txtView.setSelected(true) 

このライン

関連する問題