Sam
Sam

Reputation: 1569

Create an android ListView with margins that aren't applied to the header

I currently have a ListView in Android with a LinearLayout as a header. I would like to have a left and right margin apply to the items in the ListView, but not to the header. Is there any easy way to do this? One approach I attempted was wrapping the list items in LinearLayout, but that caused a class cast exception at runtime.

Upvotes: 0

Views: 969

Answers (2)

Adam Storm
Adam Storm

Reputation: 724

You can set the padding attribute on your ListView without affecting the parent layout. You also should be able to embed a linear layout within your parent layout but thats a seperate issue

Upvotes: 2

Ted Hopp
Ted Hopp

Reputation: 234837

Try adding left/right padding to the row view layout.

Upvotes: 1

Related Questions