如何动态地更改列表视图的分隔高度? [英] How to change the divider height of listview dynamically?

查看:182
本文介绍了如何动态地更改列表视图的分隔高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,其中应该有不同的隔高度 不同行之间。那么,怎样才能设置分隔高度 动态?

I have a listview in which there should be different divider height between different rows. So, how can we set the divider height dynamically?

假设,我有10行,应该有5分的高度 之间的第一2行,然后应该有1除法高度 下一个5行之间等。

Suppose, I have 10 rows and there should be a divider height of 5 between first 2 rows and then there should be a divider height of 1 between next 5 rows and so on.

有人可以让我知道这样做的方法是什么?

Can someone let me know the way of doing this?

推荐答案

一个方法是使分隔行。它们设置为你的的IsEnabled 适配器方法未启用。我这样做的节头,但它几乎是同样的事情。另一种方式是手工奠定了你的整个列表通过实施onLayout。如果分频器可以是空的空间,它可能工作设置顶部或底部边距为您排根视图。在XML中,这将是:

One way would be to make the dividers rows. Set them as not enabled in your isEnabled adapter method. I do that for section headers, but it is almost the same thing. Another way would be to manually lay out your whole list by implementing onLayout. If the dividers can be empty space, it might work to set top or bottom margins for the root view of your rows. In xml that would be:

    android:layout_marginTop='5px'

否则,只是让行的分隔部分。

Otherwise, just make the dividers part of the rows.

这篇关于如何动态地更改列表视图的分隔高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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