简体   繁体   中英

Android - Listview divider with specific width

I want to add dividers to listview with specific width, like the foursquare app on tips list:

预习

I don't know the proper way to do it, i tried adding a line on bottom of each item view, but the last item have a divider too, i know its a wrong way.

Is there any way to make the divider width the same of the text content?

You can set any arbitrary Drawable as a divider by calling ListView's setDrawable() method. If you know the width of the content you intend to display you can use that knowledge to make an appropriate graphic.

Also be aware that you will need to call setDividerHeight() if the drawable does not have an intrinsic height.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM