2

我正在 Titanium 中开发我的 android 应用程序。对于某些视图(例如 Ti.UI.View),我试图通过指定borderColor 和borderWidth 等属性来设置边框。但我看到的是整个视图的背景颜色与边框颜色相同。这是Titanium中的错误吗?或者我做错了什么。以下是我的代码片段。

var view = Ti.UI.createView({
  width: 200,
  height: 200,
  borderColor: '#c00',
  borderWidth: 1
});

win.add(view);

为此,我得到的是一个 200x200 像素的红色框。请让我知道是否有办法纠正这个问题。

4

1 回答 1

2

You can fix this by specifying an explicit background color:

var view = Ti.UI.createView({
  width: 200,
  height: 200,
  backgroundColor: 'blue',
  borderColor: '#c00',
  borderWidth: 1
});

If you want a transparent box with a red background, simply specify backgroundColor: transparent.

On iOS, your example produces the results you expect--that is, the background color defaults to transparent. On Android, a view with a border color and no background color defaults to using the border color as the background color.

Is this a bug in Titanium? The default behavior here differs between Android and iOS, so I'd say it is.

于 2011-11-30T18:42:00.157 回答