布局背景资源闪烁
在我设计用于平板电脑的活动中,我在 XML 中定义的 LinearLayout 上调用 setContentView,其中包含对几个不同片段的引用。 LinearLayout 中的每个片段引用的宽度都设置为 0dp,并指定了权重。
这些片段也使用 LinearLayouts 作为它们的视图。在这些 XML 中,我将背景设置为九块图像。
当我运行该应用程序时发生的情况是,九个补丁的某些部分实际上是随机出现和消失的,这让我发疯!左侧的片段包含一个WebView和一个ScrollView,右侧的片段包含一个WebView和一个ViewPager。有时,当活动加载时,所有内容都会正确绘制,但其他时候,右侧片段上将没有背景。有时,为右侧片段绘制了一半背景,然后当我与左侧片段交互时,它可能会消失并重新出现!
我花了很多时间试图弄清楚发生了什么以及我是否做错了什么。有其他人见过这个或纠正过它吗?
谢谢你!
In my activity designed for use on tablets I call setContentView on a LinearLayout defined in XML that contains references to a few different fragments. Each fragment reference in the LinearLayout has its width set to 0dp and has a weight specified.
These fragments also use LinearLayouts for their views. In the XML for those, I set the background as a nine-patch image.
What happens when I run the app is that portions of the nine-patch literally come and go randomly and it's driving me crazy! The fragment on the left contains a WebView and a ScrollView, and the fragment on the right contains a WebView and a ViewPager. Sometimes when the activity loads everything is drawn correctly, but other times there will be no background on the right fragment. Sometimes half of the background is drawn for the right fragment, and then when I interact with the left fragment, it may disappear and reappear!
I've spent a lot of time trying to figure out what is happening and if I am doing something wrong. Has anyone else ever seen this or corrected it?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将应用程序主题设置为使用空背景,并摆脱了在 setContentView 之后使用的淡入动画。所以我只需要小心地在其他布局中显式设置背景即可。疯狂。
I set the app theme to use a null background and got rid of a fade-in animation I was using after setContentView. So I just had to be careful to explicitly set the background in other layouts. Madness.