创建一个 android ListView,其边距未应用于标题
我目前在 Android 中有一个 ListView,并以 LinearLayout 作为标题。我希望将左右边距应用于 ListView 中的项目,但不适用于标题。有什么简单的方法可以做到这一点吗?我尝试的一种方法是将列表项包装在 LinearLayout 中,但这会在运行时导致类转换异常。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 ListView 上设置 padding 属性,而不会影响父布局。您还应该能够在父布局中嵌入线性布局,但这是一个单独的问题
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
尝试向行视图布局添加左/右填充。
Try adding left/right padding to the row view layout.