首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在android中为字符串应用marquee

如何在android中为字符串应用marquee
EN

Stack Overflow用户
提问于 2012-08-19 22:28:33
回答 1查看 1.5K关注 0票数 3

我正在尝试实现在android中打印字符串的样式。我能够使用静态数据,但对于动态,它并不显示标题栏样式。

当我打印时:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
String st="this is test application testing for marquee"

我喜欢这种风格。

但是,当我获得数据时,解析之后:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<TextView
        android:id="@+id/twxmorq"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:padding="5dip"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:textColor="#FF0000" />

我跑:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
myString = myString + "| "+ json_data.getString("news_title").toString();

txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setText(myString1);

当我打印mystring时,我也不喜欢它的风格。

请帮帮我。

汇总:对于字符串‘ST’,我得到了一个标题词样式的打印字符串,而对于mystring1,我没有得到marequee样式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-19 22:52:26

请使用下面的代码。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<TextView
    android:id="@+id/twxmorq"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:padding="5dip"
    android:scrollHorizontally="true"
    android:singleLine="true"
    ndroid:lines="1"
    android:textColor="#FF0000" 
    android:fadingEdge="horizontal"/>

Java代码:-

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
myString = myString + "| "+ json_data.getString("news_title").toString();

txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setSelected(true);
txt1.setText(myString1);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12033109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文