Alireza Ahmadi
Alireza Ahmadi

Reputation: 5338

Make First line height in textview the same as other lines

I have a recyclerview with bunch of textview each as an item as you see in picture below. (Blue lines aren't really there, i added them so you can see each item separately) as you can see everything seems nice and user will not notice the text is separated.

The problem is when user increases the line space(a typical option in app) line height gets bigger except the first and last line of each item and the result seems like second picture.

My question is how to find appropriate padding to set to each item so every line height seen exactly the same?

BTW i can not use just one textview for many reason!

enter image description here

enter image description here

Upvotes: 0

Views: 742

Answers (2)

Mohsen fallahi
Mohsen fallahi

Reputation: 917

just add some padding to the parent of your textview in the layout file of your list item .

for example the layout with linearlayout would be like :

<LinearLayout ........
paddingTop=15dp>

<TextView  
..........>
</TextView>

</LinearLayout> 

and you could adjust the padding dynamically if you want.

Upvotes: 1

You can increase the divider height of your listview according to linespacing height.

Or you can set an invisible view at the bottom of every row item and increase the height of this view according to linespacing height.

Or you can set padding at the bottom of every row item and increase the value of this padding according to linespacing height.

Upvotes: 1

Related Questions