简体   繁体   English

在两面板片段活动中,如何使一个片段占据整个屏幕?

[英]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.

相关问题 如何在android中显示全屏片段活动? - how to show full screen fragment activity in android? 片段正在全屏播放 - Fragment is occupying full screen in activity 同一活动上的全屏片段和非全屏片段 - Full Screen Fragment and Non Full Screen Fragment on Same Activity 如何在不显示父活动的情况下将一个全屏对话框片段替换为另一个? - how to replace one full-screen dialog fragment with another without showing parent activity? 如何在片段活动中获取用户名? - How to take username in fragment activity? 一个屏幕上有两个片段(活动),一个片段如何使用EventBus更新另一个片段 - With two fragments on one screen (activity), how can one fragment update the other with EventBus 如何在全屏上显示片段? - How to display fragment on full screen? 片段覆盖了全部活动,但活动上方的按钮仍可单击。 - Fragment cover full activity but button over activity is still clickable. 在片段中隐藏状态栏或使片段全屏 - Hide Status bar in a fragment or make the fragment full screen 全屏片段到片段过渡在片段过渡期间显示了主要活动 - Full-screen fragment to fragment transition displayed main activity during fragment transition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM