设置片段背景
我在 xml 布局中有一个列表片段和一个详细信息片段,它被设置为活动的布局。如何为每个片段设置背景图像。如果我在像 android:background=@drawable/anyimage
这样的 xml 中执行此操作,则会显示错误。我搜索过但没有得到我需要的东西,所以任何建议将不胜感激。
I have a list fragment and a details fragment in a xml layout which is set as the layout of an activity. How can I set a background image for each fragment. If I am doing it in xml like android:background=@drawable/anyimage
it shows an error. I searched but didn't get what I needed, so any suggestions will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,图像文件是空白的,并且我保存错误。可能想仔细检查一下。
编辑:中不起作用,但如果将其放入片段膨胀的布局的顶级元素中,它就会起作用。
好吧,实际上,将 android:background 放在
In my case the image file was blank and I saved it wrong. Might want to double check.
Edit:
Ok, actually, putting android:background in a <fragment> doesn't work, but it will if you put it in the top level element of a layout the fragment inflates.