Android - show footer divider but no list row divider - android

I have a list view which has a footer.
It displays numbers and at the bottom is the total.
I want to be able to show the rows without a divider between them. OTOH I DO want a divider before the summary row.
Is there any easy way to do this?

You can set android:dividerHeight to 0 in your list.
Then use custom layout for footer in which you add divider by yourself. For example, that can be a TextView with no text, android:layout_height set to 2 and android:background set to some color.

When you have custom layout for the footer, just add divider on top of it. It can be for example View of hight 2dp and different background color.

I had to do this programatically, since setting android:dividerHeight="0dip" in the XML didn't work for me:
getListView().setDividerHeight(0);

Related

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

Android listView unwanted space between header view

I'm adding 2 different views in my ListView header view but for some reason it create a 20dp space between those 2 views. How should I remove it?
Thanks!
Edit : The 2 views I add don't have any top/bottom padding or margins, I'm asking if there is any special "feature" in the ListView headerView about space/separator between views.
Edit 2: it seems that the space between the view in my header view is tied to the dividerHeight parameter. Why? I mean it should only be applied as rows separator. Is there any way to remove it from my headerView and keep it as actual row separator ? headerDividersEnabled=false don't do anything.
try to set android:headerDividersEnabled="false" in the ListView
i have same issue i have added dynamic header to listview but on the start of activity it gives space on the top of headerview and we scroll listview then header view overlaps with it instead of going up.

Android: ListView xml layout not showing background image when scrolled

I have an Activity with a ListView, I set the background image to the view programatically.
When I scroll down my list, the background image turns to white ( because my theme is Theme.Light.NoTitleBar).
How can I make it scroll with the blue background intact?
If the above point works, how can I change the text color of ListView to white instead of black?
Normal ListView
Scrolling ListView
Pressing ListView item
Use the attribute android:cacheColorHint="#000000" in ListView Tag
Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this
android:textColor="#FFF" //or #FFFFFF for white
add a attribute on the ListView Tag
android:cacheColorHint="#00000000"// setting as a transparent color
This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"
Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html
You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)
Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.

How to get some space below my last list item alone- android

I have a list whose height is set to "fill parent". everything works fine but my last item in list touches the bottom of my screen. how can i get some space below my last list item.
You can add an empty view as footer: http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View)
AFAIK there's no way to do that only with XML, you can declare the footer in XML and inflate, or create programmatically
Here is a 3-liner to add a spacer programmatically:
View listFooter = new View(this);
listFooter.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT, 70)));
listView.addFooterView(listFooter);
uhmm.. seeing that you don't want padding, print a blank line (or transparent text) on a textview located after your listview. Or print a "extra" item on your listview.
you could use the Space widget
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="10dp"/>
can simply set the margin in the list ............
if need only bottom margin then use : android:layout_marginBottom=

backgrounds in listview

i have a listview with a bunch of items in it, each item has its own background, the problem is that if i only have one item in a list, the rest of the "empty" slots of the list is black. I tried applying a background around the listview and also on the view that sorrounds it (relativeView) and i get a strange margin around the whole list like the picture at the bottom. The question i have is, how can i remove the actual "borders" around the list so it still fills upp its parent ? .
Remove any padding you may have used in your XML layout file.
Try putting in the following code in the listview's layout:
android:cacheColorHint="#00000000"
Change your listview height like this android:layout_height="fill_parent"
use android:fadingEdge="none" in listview in layout

Categories

Resources