マーキーを使ってみたが、うまくいかない。 以下は私のコードです。どこが間違っているか教えてください。
<TextView
android:text="lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00"
android:id="@+id/TextView02"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:inputType="text"
android:maxLines="1">
</TextView>
android SDK 2.0.1 を使用しています。
が動作するようになりました :) 以下にコードを添付します。
<TextView
android:text="START | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | END"
android:id="@+id/MarqueeText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true">
編集(Adil Hussainの代理):。
textView.setSelected(true)
が動作するためには、後ろのコードで設定されている必要があります。
android:singleLine="true"
android:ellipsize="marquee"
は唯一の必須属性であり、スクロールは layout_width=0dp
で定義された layout_weight
でも動作します。
以下はサンプルコードです。
<TextView
android:id="@+id/scroller"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:text="Some veryyyyy long text with all the characters that cannot fit in screen, it so sad :( that I will not scroll"
android:layout_marginLeft="4dp"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
/>
しかし、最も重要なことは、暗黙的または明示的に TextView
が選択されることです**。
でできます。
TextView txtView=(TextView) findViewById(R.id.scroller);
txtView.setSelected(true);