如何使用垂直布局?

发布于 2024-12-13 05:36:12 字数 2157 浏览 5 评论 0原文

我正在使用 Appcelerator 开发 iOS 应用程序。 在这个应用程序中,我有一个主包装视图和一些子视图。我需要使用布局垂直属性将它们放置在彼此下方,但它们都堆放在一堆(而不是单独的“行”上)。

下面的代码有什么问题?

// Create the padding view

            container = Ti.UI.createView({ 

                top: 0,
                left: 0,
                width: 320,
                height: 460,
                backgroundColor: '#000'

            });

            // Create the padding view

            wrapper = Ti.UI.createView({ 

                top: 0,
                left: 0,
                width: 320,
                height: 'auto',
                layout: 'vertical'

            });

            // Create the padding view

            label = Ti.UI.createLabel({ 

                text: e.label,
                color: e.color,
                font:{fontSize:36,fontWeight: 'normal'},
                top: 10,
                width: 'auto',
                height: 'auto'

            });

            // Create the padding view

            perks_label = Ti.UI.createLabel({ 

                text: 'Lorem Ipsum is',
                color: '#fff',
                font:{fontSize:26,fontWeight: 'normal'},
                top: 10,
                left: 10,
                width: 'auto',
                height: 'auto'

            });

            // Create the padding view

            perks_data = Ti.UI.createLabel({ 

                text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer',
                color: '#fff',
                font:{fontSize:12,fontWeight: 'normal'},
                top: 10,
                left: 10,
                width: 'auto',
                height: 'auto'

            });

            // Add label to wrapper

            wrapper.add(label);

            // Add label to wrapper

            wrapper.add(perks_label);

            // Add label to wrapper

            wrapper.add(perks_data);

            // Add wrapper to container

            container.add(wrapper);

            // Return the row

            return container;

I am developing an iOS app using Appcelerator.
In this app I got a main wrapper view and some subviews. I need them to be placed under each other using the layout vertical property but they all stack in a pile (not on separate "rows").

What is wrong with the code below?

// Create the padding view

            container = Ti.UI.createView({ 

                top: 0,
                left: 0,
                width: 320,
                height: 460,
                backgroundColor: '#000'

            });

            // Create the padding view

            wrapper = Ti.UI.createView({ 

                top: 0,
                left: 0,
                width: 320,
                height: 'auto',
                layout: 'vertical'

            });

            // Create the padding view

            label = Ti.UI.createLabel({ 

                text: e.label,
                color: e.color,
                font:{fontSize:36,fontWeight: 'normal'},
                top: 10,
                width: 'auto',
                height: 'auto'

            });

            // Create the padding view

            perks_label = Ti.UI.createLabel({ 

                text: 'Lorem Ipsum is',
                color: '#fff',
                font:{fontSize:26,fontWeight: 'normal'},
                top: 10,
                left: 10,
                width: 'auto',
                height: 'auto'

            });

            // Create the padding view

            perks_data = Ti.UI.createLabel({ 

                text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer',
                color: '#fff',
                font:{fontSize:12,fontWeight: 'normal'},
                top: 10,
                left: 10,
                width: 'auto',
                height: 'auto'

            });

            // Add label to wrapper

            wrapper.add(label);

            // Add label to wrapper

            wrapper.add(perks_label);

            // Add label to wrapper

            wrapper.add(perks_data);

            // Add wrapper to container

            container.add(wrapper);

            // Return the row

            return container;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑叹一世浮沉 2024-12-20 05:36:12

看来 perks_label 和 perks_data 的顶部和左侧应该不同。尝试将 perks_data 设置为 top:50。

谢谢,

It seems like the top and left of perks_label and perks_data should be different. Try setting the perks_data to top:50.

Thanks,

熊抱啵儿 2024-12-20 05:36:12

我以前也碰过这堵墙。您是否将当前窗口的布局设置为“垂直”?因此,从添加容器的窗口中,将其布局设置为垂直:

var win = Titanium.UI.currentWindow;
win.layout = 'vertical';

I've hit this wall before. Have you set the layout for the current window to 'vertical'? So, from the window that you add the container to, set its layout to vertical:

var win = Titanium.UI.currentWindow;
win.layout = 'vertical';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文