首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Android中的字幕文本

Android中的字幕文本
EN

Stack Overflow用户
提问于 2010-02-02 16:01:59
回答 16查看 112.4K关注 0票数 72

如何在android应用程序中使用字幕文本?

EN

回答 16

Stack Overflow用户

回答已采纳

发布于 2010-08-30 16:16:44

下面是一个示例:

代码语言:javascript
复制
public class TextViewMarquee extends Activity {
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView) this.findViewById(R.id.mywidget);  
        tv.setSelected(true);  // Set focus to the textview
    }
}

包含文本视图的xml文件:

代码语言:javascript
复制
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/mywidget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:textColor="#ff4500"
        android:text="Simple application that shows how to use marquee, with a long text" />
</RelativeLayout>
票数 140
EN

Stack Overflow用户

发布于 2011-07-12 16:57:00

代码语言:javascript
复制
TextView textView = (TextView) this.findViewById(R.id.textview_marquee);  
textView.setEllipsize(TruncateAt.MARQUEE);
textView.setText("General Information... general information... General Information");
textView.setSelected(true);
textView.setSingleLine(true);
票数 25
EN

Stack Overflow用户

发布于 2010-02-02 16:24:57

代码语言:javascript
复制
android:ellipsize="marquee"

只有当你的TextView拥有焦点时,这才能起作用。

票数 24
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2182578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档