I am working on an app using ListView in the form of a chat app. I was wondering if it is possible to style individual items in a ListView by giving the items padding (left) and padding (right). Should I style the items programatically or are there other options?
Asked
Active
Viewed 174 times
0
-
It is better to use a custom listview when you want to specifically customize the items in your list. – Clint Paul May 16 '18 at 09:22
-
1It is possible, there is a concept of view types, check [this SO response](https://stackoverflow.com/questions/4777272/android-listview-with-different-layouts-for-each-row). Also a suggestion: forget about ListView and use ReyclerView. It's the officially preferred way for making lists. – Josef Adamcik May 16 '18 at 09:25
-
I will look into RecyclerView. Thanks for the advice! – Haris Spahija May 16 '18 at 09:52
1 Answers
0
As you haven't posted the code, I am providing the answer in text version. You need to use custom layouts using custom adapters. There you will have two layouts, one where you add the ListView and another where you add the single item that you want to create. This single item layout should be inflated and populated in the ListView Adapter. In this single item layout you can set left padding and right padding.

theanilpaudel
- 3,348
- 8
- 39
- 67