简体   繁体   English

通过点击按钮将线性布局更改为约束布局

[英]Change linear layout to constraint layout by hitting a button

So the screen is going to have some textViews and a button, by hitting the button, the layout should change from linear to constraint, vice versa.所以屏幕将有一些 textViews 和一个按钮,通过点击按钮,布局应该从线性变为约束,反之亦然。 these two should have exact same paddings and alignments.这两个应该具有完全相同的填充和对齐。 I have my linear layout set up, how do I make an extra screen to perform constraint layout?我设置了线性布局,如何制作额外的屏幕来执行约束布局?

do I simply hide and unhide components?简单地隐藏和取消隐藏组件? or is there a way to overlap the components?或者有没有办法重叠组件? maybe create another layout.xml something like that?也许创建另一个 layout.xml 类似的东西?

You can make an copy of your linear layout.您可以复制您的线性布局。

Then open the copied new layout in design view, right click the root LinearLayout object in the hierarchy view, select "Convert LinearLayout to ConstraintLayout" from the popup menu.然后在设计视图中打开复制的新布局,在层次视图中右键单击根 LinearLayout 对象,从弹出菜单中选择“将 LinearLayout 转换为 ConstraintLayout”。

I don't think it can create 100% same layout, but good luck!我不认为它可以创建 100% 相同的布局,但祝你好运!

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

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