I am currently writing an Android application that uses a ListView with headers. This works fine, but not the way I want. Each item in a ListView has a 1-2px separator at the top and bottom of it. Same title - and this is the problem. It doesnโt look very beautiful ...

The interesting part is that system applications (for example, "Settings") do not have such a problem.

Here is my adapter example:
setListAdapter(new BaseAdapter() { @Override public int getCount() { return 10; } @Override public Object getItem(int i) { return i; } @Override public long getItemId(int i) { return i; } @Override public View getView(int i, View view, ViewGroup viewGroup) { View v = ((LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(i % 3 == 0 ? R.layout.list_header : android.R.layout.simple_list_item_1, viewGroup, false); ((TextView)v.findViewById(android.R.id.text1)).setText("test"); return v; } });
And the header list layout file:
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello, World" style="?android:attr/listSeparatorTextViewStyle"> </TextView>
So, the question arises: how to get rid of element separators between headers and regular elements, such as a settings application?
EDIT: After reading the answers, I want to clarify one thing. I do not want to completely remove the delimiters. I want to remove them only between headers and regular elements. In addition, half measures, such as โremoving separators completely and adding them to some itemsโ, also do not satisfy me.
java android user-interface android-listview listview
m4tx
source share