gpt4 book ai didi

android - 选取框不在 android 中滚动

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:46:47 27 4
gpt4 key购买 nike

我想在我的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com