android - 选取框不在 android 中滚动

标签 android marquee

我想在我的 android 应用程序中使用选取框的功能,并使用此代码来实现目标:

 <TextView
    android:id="@+id/marqueetext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:lines="1"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:text="hello all how are you"
    android:textColor="#ff4500" 
    />

MarqueeText = (TextView)ShowTheMessages.this.findViewById(R.id.marqueetext);
        MarqueeText.setSelected(true);

我不知道为什么它不起作用。我浏览了很多相关帖子但没有找到解决方案。请帮助我。在此先感谢。

最佳答案

更改此行并尝试...

android:text="hello all how are you hello all how are you hello all how are you hello all how are you"
TextView txtView=(TextView) findViewById(R.id.marqueetext);
txtView.setSelected(true);

 <TextView
    android:id="@+id/marqueetext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:lines="1"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:text="hello all how are you hello all how are you hello all how are you hello all how are you"
    android:textColor="#ff4500" 
    />

或者另一个例子是...

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/marqueetext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:lines="1"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:textColor="#ff4500"
        android:text="hello all how are you hello all how are you hello all how are you hello all how are you hello all how are you" />
</RelativeLayout>

关于android - 选取框不在 android 中滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13486935/

相关文章:

android - 自定义首选项类别标题

javascript - Android:JS Bundle 未从 Metro Bundler 服务器加载

android - 调用 Sinch REST API 时出现 400 错误

javascript - 选取框不显示所有文本 - 在不同点切断

css - 使用css3的跑马灯效果

html - 为什么选取框在悬停时不停止?

android - 如何删除 SQLITE 数据库中的第一行?

android - 在 MPAndroidChart PieChart 中禁用拖动

安卓选框不工作

Flutter - Marquee 没有为类 'MyApp' 定义