TextView的跑马灯不工作跑马灯、工作、TextView

2023-09-11 11:33:57 作者:笔起掀墨浪。

我曾尝试使用帐篷和它不工作 这里是我的code,请让我知道我去错了

I have tried to use marquee and its not working here is my code, please let me know where im going wrong

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

我使用的Andr​​oid SDK 2.0.1

i am using android SDK 2.0.1

推荐答案

现在的工作:) 下面附

working now :) Code attached below

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

修改(代表阿迪尔·侯赛因):

textView.setSelected(真)需要在code被设置为后面这个工作。

textView.setSelected(true) needs to be set in code behind for this to work.