简体   繁体   中英

Android layouts and screen rotation

我今天遇到的另一个问题...我正在寻找与秋千上的flowLayout类似的东西,我一直在寻找却什么也没发现...我需要一些布局,当空间不足时,我要在其中放置3个按钮(在以potrait模式为例)我希望它们像一个按钮一样显示,占据100%的布局空间,而另两个按钮则位于第一个按钮的下方,当有足够的空间时(横向模式),我希望它们以相同的权重放置一条线。我考虑过相对布局,但它缺少重量,另一方面,线性布局不符合我所阅读内容的要求。

What you could try is overriding the onConfigurationChange method of the activity and try implementing some logic there to change the position of the views depending on the orientation of the device. Or in your oncreate you could instantiate all your views and hide a complete set of controls for one type of orientation and then on another type do the opposite. Ive done both of these and hiding and unhiding the views seemed to be the least performance taxing because everything was instantiated once in oncreate. You could also try using seperate layouts all together for each orientation which might decrease performance due to view inflation but if your views are not to complex you might not notice anything except on lesser devices.

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