当我从同一 ListView 行更新不同的 TextView 时,TextView 滚动正在重置 [英] TextView scrolling is resetting when I update a different TextView from the same ListView row

查看:32
本文介绍了当我从同一 ListView 行更新不同的 TextView 时,TextView 滚动正在重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,对于一个特定的项目,我每秒刷新剩余时间.它工作正常,但我有一个小错误.每当我打电话

I have a listview and for a specific item I'm refreshing the remaining time every second. It works fine, but I'm having a small bug. Whenever I call

duration.setText(newRemainingValue);

为了更新值,来自同一行的另一个 textView 会受到影响.这个另一个 textVewi 显示一个 scolling 文本

to update the value, another textView from the same row is impacted. This other textVewi displays a scolling text

title.setSelected(true);
title.setEllipsize(TruncateAt.MARQUEE);

每当我更改第一个 textView 值时,第二个值都会重置滚动并从头开始滚动.看起来这个问题仅在我在 ListView 中执行此操作时才会出现

and whenever I change the 1st textView value, the second one resets the scrolling and starts scrolling from the beginning. It looks like this issue is only present when I do this in a ListView

知道如何解决这个问题吗?

Any idea how to fix this ?

推荐答案

听起来 textviews 被设置为 wrap_content.每当文本更改时,这将触发布局传递.尝试使用 match_parent 或将宽高设置为固定值,这样更改文本就不会触发布局传递

It sounds like the textviews are set to wrap_content. That will trigger a layout pass whenever the text is changed. Try using match_parent or setting the width and height to a fixed value, so that changing the text will not trigger a layout pass

这篇关于当我从同一 ListView 行更新不同的 TextView 时,TextView 滚动正在重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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