2016-06-18 3 views
0

私はマーキーでアニメーション化されたテキストビューでニュースバーを作成しようとしています。AndroidでSpannable Marquee TextViewを使ってニュースバーを作成するには?

私はmarqueeRepeatLimit = "marquee_forever"

    <TextView 
         android:id="@+id/scroll_notifs" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:singleLine="true" 
         android:ellipsize="marquee" 
         android:marqueeRepeatLimit="marquee_forever" 
         android:scrollHorizontally="true" 
         android:padding="10dp" 
         android:gravity="center" 
         android:focusable="true" 
         android:focusableInTouchMode="true" 
         android:background="@color/black_scrollTextView" 
         android:textColor="@color/white" 
         android:textSize="@dimen/text_size_s" 
         android:visibility="gone" 
         android:freezesText="true"/> 

でこのビューを使用して、私はコードで設定:ニュースバーのようなTextViewの行為

TextView scroll_notifs = (TextView) view.findViewById(R.id.scroll_notifs); scroll_notifs.setSelected(true);

とうまくアニメーション、問題今テキストビューの一部をクリック可能にする方法ですが、私はそのような文字列を使用しました:

SpannableString spannableString = new SpannableString("this is the fancy box"); 

    spannableString.setSpan(new ClickableSpan() { 
     @Override 
     public void onClick(View view) { 
      TextView textView = (TextView) view; 
      CharSequence charSequence = textView.getText(); 
      Log.d("span click",charSequence.toString()); 
     } 
    }, 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 

    scroll_notifs.setText(spannableString); 

    scroll_notifs.setMovementMethod(LinkMovementMethod.getInstance()); 

クリックは機能しますが、動きのあるスパンには追従しません。テキストビューの最初のピクセルをクリックすると機能します。スパンが0から始まり3で終了するからです。

マーキーが繰り返され、私はスパンをクリックし始め、それに続いてアニメートされ、応答しません。

このように、別のクリックリスナーを使用してニュースバーを作成するには、さまざまな方法があります。

よろしく

答えて

関連する問題