菜鸟教程小白 发表于 2022-12-12 17:12:09

android - 诸如自动布局或约束之类的东西


                                            <p><p>我刚开始使用 SpriteBuilder,想知道应用程序是否可以使用“自动布局”(基本形式)之类的功能?你看我做了这个简单的布局(<a href="http://cl.ly/Szs3" rel="noreferrer noopener nofollow">http://cl.ly/Szs3</a>),包含一个标题(蓝色)和正文(红色)。</p>

<p>现在我想要的是标题有一个固定的高度(它有 100% 的宽度,所以这很好)并且红色 block “填充”了屏幕的其余部分。因此,当设备更高时,可以同时显示更多内容。</p>

<p>这可能吗?如果是这样,我怎么能做到这一点。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><strong>是的,有这样一个选项,只是命名有点不同。</strong></p>

<p>我将示例项目上传到此 GitHub 存储库:<a href="https://github.com/MakeGamesWithUs/Spritebuilder-Simple-Autosizing" rel="noreferrer noopener nofollow">https://github.com/MakeGamesWithUs/Spritebuilder-Simple-Autosizing</a> </p>

<p>您的顶部容器需要一个静态高度、一个相对位置和一个为 1 的 Yanchor 。这样顶部容器的大小始终为 100 磅,并且始终位于屏幕顶部:
<img src="/image/yklEh.png" alt="enter image description here"/> </p>

<p>您的底部容器需要 100 的 <em>height inset</em>,这意味着您的容器将使用父容器的完整高度,顶部的 100 点除外:</p>

<p> <img src="/image/rPy9E.png" alt="enter image description here"/> </p></p>
                                   
                                                <p style="font-size: 20px;">关于android - 诸如自动布局或约束之类的东西,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/20638148/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/20638148/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: android - 诸如自动布局或约束之类的东西