安卓跑马灯

发布于 2024-10-06 04:43:05 字数 332 浏览 1 评论 0原文

android 中有 Marquee 的工作示例吗?我浏览了一些网站,但这些例子不起作用。

谢谢您的回答。但是下面的代码无论如何都不起作用。我使用的是安卓2.2。

       <TextView    
             android:singleLine="true"  
             android:ellipsize="marquee" 
             android:marqueeRepeatLimit ="marquee_forever"
             android:text="Marquee.."/> 

Is there any working example for Marquee in android? I went through some sites, but that examples are not working.

Thank you for the answers.. But the following code is not working anyway. I am using Android 2.2.

       <TextView    
             android:singleLine="true"  
             android:ellipsize="marquee" 
             android:marqueeRepeatLimit ="marquee_forever"
             android:text="Marquee.."/> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

可可 2024-10-13 04:43:05

通过 XML 很容易做到。使用以下设置:

android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="false"
android:scrollHorizontally="true"

如果您的 TextView 位于relativelayout 中,则宽度或高度必须是静态的(即 32dp)。如果需要动态,请将 TextView 放置在relativelayout 内的另一个视图中。

在onCreate()中,您需要选择TextView:

myTextView.setSelected(true);

it's easy to do via XML. Use the following settings:

android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="false"
android:scrollHorizontally="true"

If your TextView is within a RelativeLayout, the width or height will have to be static (i.e. 32dp). If you need dynamic, place the TextView in another View within the RelativeLayout.

In onCreate(), you need to make the TextView selected:

myTextView.setSelected(true);
终止放荡 2024-10-13 04:43:05

您缺少的代码行是:

    android:focusable="true"
    android:focusableInTouchMode="true"
    android:singleLine="true"

在文本字段中尝试此文本,因为它是长文本。

android:text="This is a very long text which is not fitting in the screen so it needs to be marqueed."

检查我的完整代码并逐步进行此处< /a>

The code lines you were missing are :

    android:focusable="true"
    android:focusableInTouchMode="true"
    android:singleLine="true"

In the text field try this text as it is a long text.

android:text="This is a very long text which is not fitting in the screen so it needs to be marqueed."

Check my complete code and step by step process here

魔法唧唧 2024-10-13 04:43:05

你忘记了在java中执行此操作..

tv.setSelected(true);

并且xml将是

android:scrollHorizontally="true"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="false"
android:marqueeRepeatLimit="marquee_forever"

You have forgotten to do this in java..

tv.setSelected(true);

and the xml will be

android:scrollHorizontally="true"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="false"
android:marqueeRepeatLimit="marquee_forever"
誰認得朕 2024-10-13 04:43:05

使用 android:ellipsize="marquee"

 <TextView  
    android:id="@+id/secondLine"   
    android:singleLine="true"
    android:ellipsize="marquee"
    android:text="Simple application marquee sample..."/>

Keeo Text 足够大,以使其执行选取框效果。

Use android:ellipsize="marquee"

 <TextView  
    android:id="@+id/secondLine"   
    android:singleLine="true"
    android:ellipsize="marquee"
    android:text="Simple application marquee sample..."/>

Keeo Text to large enough to let it perform marquee effect..

窝囊感情。 2024-10-13 04:43:05

您可以设置 ellipsize=marqueemarqueeRepeatLimit 属性:

例如:我为 TextView 设置了:

 android:ellipsize="marquee"
 android:marqueeRepeatLimit ="marquee_forever"

您可以请参阅此问题以获取最佳信息: 有没有办法让 ellipsize="marquee" 始终滚动?

You can set ellipsize=marquee and marqueeRepeatLimit attribute:

For example: I have set for the TextView:

 android:ellipsize="marquee"
 android:marqueeRepeatLimit ="marquee_forever"

You can refer this SO Question for the best information: Is there a way to make ellipsize="marquee" always scroll?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文