How to dynamically change the height of a list separator?

I have a list in which there should be a different height for the separator between different lines. So how can we set the height of the separator dynamically?

Suppose I have 10 lines, and there should be a height of separator 5 between the first two lines, and then there should be a height of separator 1 between the next 5 lines, etc.

Can someone tell me how to do this?

+4
source share
1 answer

One way is to make separator strings. Set them as inactive in your isEnabled adapter. I do this for section headings, but it is almost the same. Another way is to manually list the whole list by doing onLayout. If the delimiters can be white space, you may need to set upper or lower margins for the root representation of your lines. In xml, it will be:

  android:layout_marginTop='5px' 

Otherwise, just make the delimiters part of the lines.

+2
source

Source: https://habr.com/ru/post/1308531/


All Articles