钛:图像-> “自动" [英] Titanium: Image -> "auto"

查看:72
本文介绍了钛:图像-> “自动"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有一个名为hello.png的图像,尺寸为200x100. 我像这样使用hello.png创建一个按钮:

Let's say I have an image called hello.png with dimensions 200x100. I create a button using that hello.png like this:

var button = Titanium.UI.createButton({
bottom : 50,
backgroundImage : "images/hello.png",
width:100,
height:"auto";
});
window.add(button);

设备上按钮高度的外观是什么? 是200像素还是远小于200(也许是50)?

What would be the appearance of the height of the button on the device? Would it be 200 pixels or would it be much less than 200 (maybe say 50)?

根据我在Google上找到的内容,该按钮应为200像素.但是当我编译应用程序时,按钮高度大大缩小了:/

Based on what I've found on google, the button should be 200 pixels. But when I compile the app, the button height is greatly shrunken :/

推荐答案

如果避免使用height=auto,它将起作用.在某些情况下,它将采用父高度,而自动高度值将不等于父窗口高度. .在下面的代码示例中,它将起作用,因为按钮的宽度将固定为100,但是高度将根据窗口的大小而变化.

If you avoid the height=auto, it will work.It will take the parent height in some case the auto height value wont be equal to the parent window height. In the below code sample it will work as the button width will be fixed to 100 but the height will be changing accordance with the window size.

var window = Titanium.UI.createWindow();
var button = Titanium.UI.createButton({
    bottom : 50,
    backgroundImage : "assets/images/boston_college.png",
    width:100
});
window.add(button);
window.open();

这篇关于钛:图像-> “自动"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆