android - 即使尝试了所有方法,我也无法在 Android 中获得字幕效果

标签 android marquee

<分区>

public class Crunk extends Activity {
    TextView textView = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_crunk);
        Button button = null;

        button = (Button)findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Log.e("It's Clicked", "Don't Worry");
                textView.setText("SeeMe");
                textView.setEllipsize(TruncateAt.MARQUEE);

            }
        });
        textView = (TextView)this.findViewById(R.id.textView1);
        textView.setSelected(true);
        textView.setText("Waitin'....");
    }

此代码仅显示文本,不显示字幕效果。

帮我弄出效果。

我希望文本在点击按钮时显示效果。

尝试了大部分方法还是得不到想要的效果....

        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="180dp"
    android:text="@string/TapMe" />

<TextView
    android:text="@string/SeeMe"
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="51dp"

    android:textAppearance="?android:attr/textAppearanceLarge" />

最佳答案

您可以在 layout.xml 中设置这些属性

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

关于android - 即使尝试了所有方法,我也无法在 Android 中获得字幕效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21577707/

相关文章:

android - 获取 ImageButton 的背景作为位图

java - JSF - 重新加载后字幕不显示任何内容

android - 将数据发送到串行 Android 应用程序

android - 无法在模拟器 Android Studio 中启动 AVD

c# - 如何让标签文字自动滚动?

jquery - "jQuery("#marquee ").marquee is not a function"错误

silverlight - 在 Silverlight 中计算选取框类型动画的速度

css - 如何在数据选框中添加 anchor href

android - 使用 Android Navigation 组件的深层链接和动画

Android YouTubePlayer 在播放器顶部带有未经授权的覆盖