How to change the divider height of listview dynamically?

跟風遠走 提交于 2019-12-30 07:03:11

问题


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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/2749551/how-to-change-the-divider-height-of-listview-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!