简体   繁体   English

如果更改屏幕方向,如何修复按钮大小?

[英]How to fix button size if changing screen orientation?

I have this app wherein in requires to change the screen orientation.我有这个应用程序,其中需要更改屏幕方向。 First image is for portrait and Second image is for landscape.第一张图片是纵向的,第二张图片是横向的。 But there are instances that the two(2) buttons become large when I change the orientation from landscape to portrait.但是在某些情况下,当我将方向从横向更改为纵向时,两 (2) 个按钮会变大。 The third image will show you how big the buttons after changing orientation which is it does not follow the correct portrait layout.第三张图片将向您显示更改方向后按钮的大小,即它不遵循正确的纵向布局。

portrait肖像

这是纵向时的正确布局

landscape景观

这是横向时的正确布局

bigger button when changed orientation改变方向时更大的按钮

改变方向时较大的按钮

The solution I tried was the image below:我尝试的解决方案是下图:

Attached equal heights附加等高

附加到滚动视图

子布局

Set to 0.18 proportional height设置为 0.18 比例高度

比例高度

I am having a hard time to fix this issue aside from, it is the first time I encountered this issue, the issue does not appear 100% and this issue usually appear in iPhoneX series specifically iPhoneX.我很难解决这个问题,这是我第一次遇到这个问题,这个问题不是 100% 出现的,而且这个问题通常出现在 iPhoneX 系列,特别是 iPhoneX 中。 Hope you can help me regarding this.希望你能帮助我解决这个问题。 Thank you in advance.先感谢您。

Always use size class to handle objects in different screens.始终使用尺寸 class 来处理不同屏幕中的对象。 Or the other option is to use Stack.或者另一种选择是使用堆栈。 But size class is always the best option.但尺寸 class 始终是最佳选择。

Use vary for traits (Size classes) and provide constraints for width & height for each button for different orientations.对特征(大小类)使用变化,并为不同方向的每个按钮提供宽度和高度约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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