如何给listview添加跑马灯效果?

2024-03-26

我在 ArrayList 中有我的朋友列表,我正在尝试使用 ArrayAdapter 和 rowlayout.xml 在列表视图中显示它

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/rowlayout"
android:padding="10dp"
>

现在我想为其添加选框效果。我想永远滚动这个列表视图。 为此我添加了以下代码

android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"

但是这段代码阻止了我的 ListView 的 OnLongClickListner 效果。

我不知道为什么?


   android:ellipsize="marquee"
            android:gravity="left"
            android:lines="1"
            android:scrollHorizontally="true"

android:singleLine 已弃用,可聚焦 - 也不需要

此布局适用于新的示例项目:

<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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:scrollHorizontally="true"
        android:text="12312312321321312312321321312311321321321312321312312123132132132" />

</RelativeLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何给listview添加跑马灯效果? 的相关文章

随机推荐