简体   繁体   中英

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" ? 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"?

In terms of UI load, there is very little difference between these two. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM