This is what I want to obtain (note - the blue is only hilited):
A ListView with rounded corners and children of it with with white-lightgrey background of every n-th.
And I have this MyArrayAdapter
to paint every 2nd row in different color:
public class AlternateRowArrayAdapter extends ArrayAdapter
{
private int[] colors;
public AlternateRowArrayAdapter(@NonNull Context context, @LayoutRes int layout,
@IdRes int textViewResourceId, @NonNull List<String> objects)
{
super(context, layout, textViewResourceId, objects);
colors = new int[] {ResourcesCompat.getColor(context.getResources(), R.color.white, null) ,
ResourcesCompat.getColor(context.getResources(), R.color.lmsLightGrey, null)};
}
/**
* Display rows in alternating colors
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
int colorPos = position % colors.length;
view.setBackgroundColor(colors[colorPos]);
return view;
}
}
Although the children of ListView doesnt respect the border radius of parent and put this background color to full rectangle of theirs:
How can I tell children to obey it's parent border radius?