[英]In two-panel fragment Activity, how to make one fragment take over full screen?
On tablets, one of my activities has a split screen - a list in the left panel, and a map in the right. 在平板电脑上,我的一项活动有一个分割屏幕-左侧面板中的列表和右侧地图。
If a user wants to maximize the map fragment, is it better to set the left fragment to a 0dp
width, or set android:visibility="gone"
? 如果用户想最大化地图片段,最好将左侧片段设置为
0dp
宽度,还是设置android:visibility="gone"
? If the latter, will it's lifecycle events still be called? 如果是后者,是否还会调用其生命周期事件? (ie If the user then exits the application, and re-enters later.)
(即,如果用户随后退出该应用程序,然后稍后再次输入。)
is it better to set the left fragment to a 0dp width, or set android:visibility="gone"?
将左片段设置为0dp宽度还是设置android:visibility =“ gone”更好?
In terms of UI load, there is very little difference between these two. 就UI负载而言,这两者之间的差异很小。 Regardless of the option you choose, the left fragment would still be inflated (even though it's not visible to the user).
无论您选择哪种选项,左侧片段都会被放大(即使用户看不见)。 So basically, it's your choice.
因此,基本上,这是您的选择。 My preference is usually to alter the visibility (gone/visible) but then, that's just a personal preference.
我的喜好通常是更改可见性(消失/可见),但这只是个人喜好。
If the latter, will it's lifecycle events still be called?
如果是后者,是否还会调用其生命周期事件?
Yes. 是。 The visibility of a view does not affect/determine its lifecycle.
视图的可见性不会影响/确定其生命周期。
I hope this helps. 我希望这有帮助。 Merry coding!
编码愉快!
Yes. 是。 Its lifecycle events will be triggered.
其生命周期事件将被触发。 Because fragment lifecycle does not depend on the UI but on the connection to the fragmentManager of an activity.
因为片段的生命周期不取决于UI,而是取决于与活动的fragmentManager的连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.