如何添加滚动字幕效果的ListView? [英] How to add marquee effect to listview?

查看:138
本文介绍了如何添加滚动字幕效果的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的ArrayList中与放大器的好友列表;我试图使用ArrayAdapter和放列表视图中显示它; rowlayout.xml

 < TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =match_parent
机器人:ID =@ + ID / RowLayout的
机器人:填充=10dp
>
 

现在我想添加滚动字幕效果吧。我希望永远滚动此列表视图。 对于这一点,我加入以下code

 安卓ellipsize =金字招牌
机器人:可聚焦=真
机器人:focusableInTouchMode =真
机器人:freezesText =真
机器人:marqueeRepeatLimit =marquee_forever
机器人:以下属性来=15dip
机器人:paddingRight =15dip
机器人:scrollHorizo​​ntally =真
机器人:单线=真
 

但是,这code停止列表视图我OnLongClickListner效果。

我不知道为什么?

解决方案

 安卓ellipsize =金字招牌
            机器人:重力=左
            机器人:行=1
            机器人:scrollHorizo​​ntally =真
 

安卓SINGLELINE是depricated,也需要可获得焦点 - 不是

这个布局工作在一个新的样本项目:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

    <的TextView
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_centerHorizo​​ntal =真
        机器人:layout_centerVertical =真
        机器人:ellipsize =金字招牌
        机器人:marqueeRepeatLimit =marquee_forever
        机器人:以下属性来=15dip
        机器人:paddingRight =15dip
        机器人:scrollHorizo​​ntally =真
        机器人:文本=12312312321321312312321321312311321321321312321312312123132132132/>

< / RelativeLayout的>
 

I have list of my friends in ArrayList & i am trying to display it in listview using 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"
>

Now i want to add marquee effect to it.I want to scroll this listview forever. For this i added following code

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"

But this code stop my OnLongClickListner effect of listview.

I don't know why?

解决方案

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

android:singleLine is depricated,focusable -not needed too

This layout works in a new sample project:

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

这篇关于如何添加滚动字幕效果的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆