【问题标题】:How to add marquee effect to listview?如何为列表视图添加选框效果?
【发布时间】:2014-02-12 23:40:50
【问题描述】:

我在 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 android-layout


    【解决方案1】:
       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>
    

    【讨论】:

    • 谢谢,但这对我不起作用。现在 OnLongClick 效果有效,但文本不滚动。
    • 是的。它有效。谢谢。我们可以垂直滚动所有列表项吗?
    • +1 android:singleLine is depricated,focusable -not needed too
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多