TextView 选框不起作用 [英] TextView Marquee Doesn't Work

查看:29
本文介绍了TextView 选框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了所有方法,我可以想到让这种选取框效果起作用.这是我的 xml:

I've tried all, I can think of to get this marquee effect to work. Here is my xml:

<TextView android:id="@+id/curPlaying"
    android:layout_width="320dp"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:ellipsize="marquee"
    android:scrollHorizontally="true"
    android:singleLine="true"
    android:marqueeRepeatLimit ="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true" 
    android:textColor="#83A602"
    android:textSize="20dp"
    android:text="Nothing Loaded" />

我将其设置为在代码中选择.我认为它可能不起作用的唯一原因是文本以相对频繁的间隔被代码修改.

And I'm setting it as selected in code. The only thing why I think it might not be working is the text is getting modified by the code at relatively frequent intervals.

帮助?

推荐答案

请尝试下面的代码,它对我来说工作正常...

Hi Please try below code it is working fine for me...

<TextView
            android:id="@+id/mywidget"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:lines="1"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:text="Simple application that shows how to use marquee, with a long text"
            android:textColor="#ff4500" />

<小时>

TextView tv = (TextView) this.findViewById(R.id.mywidget);
        tv.setSelected(true); // Set focus to the textview

它适用于我的三星 Galaxy ACE 手机.

It is working on My Samsung Galaxy ACE Phone.

这篇关于TextView 选框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆