Removing default padding in listview items within Android studio - android

Can someone provide me with any insights on how to remove the default padding around a listview item? I have provided an image with arrows indicating what padding I am talking about.

You need to create custom a custom layout file for your list items. And a custom adapter. Then you can control all the appearance.

Related

How to set padding left/right listview items individually

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?
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.

Removing Dividers and Adding Space between Expandable List Groups Android

I'm working on my theme in android and am having a heck of a time getting my Expandable List Views to look right. Here is my desired effect.
Collapsed
Expanded
So I primarily want the space between each List Group. And since android also adds those dividers I want to get rid of all of them.
Here is what I'm getting without trying any trickery.
Collapsed
Expanded
I assumed the best way to get my desired look would be to put a margin on the list group layout xml file but I get end up getting this. It does not put a spacer on my group indicator and also puts the space between the group and the child which I don't want.
Collapsed
Expanded
Any help or a push in the right direction would be greatly appreciated. Thank You!
You can use these properties of listview dont know if it will solve your problem though:
android:divider="#FFF" // same as your background
android:dividerHeight="0dp"//for not showing one
android:divider="#android:color/transparent" //setting divider to transparent
android:dividerHeight="-1dp"//setting negative height also works but only on relative and linear layout according to google engineers but I have tested it to work in many scenarios use this with care

remove bottom divider of a android ExpandedListView

So I am trying to remove the top and bottom (or header and footer if you will) dividers from the listsviews within each group of a ExpandableListView. I saw this link (Remove the bottom divider of an android ListView) but that does not seem to work with the ExpandableListView. Does anyone have a way to do this within code or XML markup? I can disable them all together and do it with in the item layout, but since I share that with nother list I do not really want to go that route unless I have too.
I am targeting Honeycomb (3.1).
Have you tried setting the android:childDivider xml attribute to 0px?

ListView Scrolling

I have three items in a ListView. The reason I have chosen the ListView is so I can use a Divider and a List Selector on these items.
However I do not need/want the scrolling aspect of the ListView. Ie. When I select/drag an item from the list, I dont want it to scroll..
Is it possible to disable this somehow? Or will I have to add the items using a LinearLayout and find another way of using a list divider and selector?
I'm not sure how well this will work for you, but you can disable overscroll (available in android-9 and above):
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
and then also hide the scroll bars:
listView.setVerticalScrollBarEnabled(false);
After this, if your list does not exceed the screen size then it shouldn't be able to scroll.
If you dont need to scroll listview, you can add the list item to a linear layout as well you can design it also through xml file.
And for put a DIVIDER to it just take a "View" widget.
Put it height 1 dip and width fill_parent. You can give color to this view through background color.
Try it. i have done it many times.

Android ListView different divider images

In ListView I can change the divider image using android:divider=image but I want to display different divider images for different items how can I do that ?
Why not have no divider images and make the divider part of the View for each item?
For example, at the top of the view you have a label and an icon and at the bottom you have your divider image.
AFAIK there is no means to have different dividers in different locations in a single list. Either follow Mr. Webb's recommendation (i.e., put the "dividers" in the list items), or keep a consistent divider, or perhaps subclass/reimplement ListView to provide the functionality you seek.

Categories

Resources