我正在使用 Titanium SDK 开发多平台应用程序。 那么这段代码在 iOS 上运行良好,但在 Android 上运行不佳。 我在这里写 .tss 和 .xml 代码。
----------------.tss文件------------------------
".container": {
backgroundColor:"white"
}
"#select_language_pannel": {
layout: 'vertical',
width: '84%',
height: '45%',
image: '/images/select_language_pannel.png'
}
"#language_label":{
top: '20%',
color : '#008c99',
width: '100%',
textAlign: 'center',
text: L('select_language'),
font: {fontSize: '18dp', fontWeight:"bold"}
}
"#arabic_button": {
layout: 'vertical',
top: '40%',
width: '64%',
height: '13%',
backgroundImage : '/images/btn_login_common_normal.png',
backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}
"#arabic_text": {
layout: 'vertical',
color: '#008c99',
height: '100%',
highlightedColor: '#FFFFFF'
}
"#english_button": {
layout: 'vertical',
top: '60%',
width: '64%',
height: '13%',
backgroundImage : '/images/btn_login_common_normal.png',
backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}
"#english_text": {
color: '#008c99',
height: '100%',
highlightedColor: '#FFFFFF'
}
"#select_language_pannel": {
layout: 'vertical',
width: '84%',
height: '45%',
image: '/images/select_language_pannel.png'
}
"#language_label":{
top: '20%',
color : '#008c99',
width: '100%',
textAlign: 'center',
text: L('select_language'),
font: {fontSize: '18dp', fontWeight:"bold"}
}
"#arabic_button": {
layout: 'vertical',
top: '40%',
width: '64%',
height: '13%',
backgroundImage : '/images/btn_login_common_normal.png',
backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}
"#arabic_text": {
layout: 'vertical',
color: '#008c99',
height: '100%',
highlightedColor: '#FFFFFF'
}
"#english_button": {
layout: 'vertical',
top: '60%',
width: '64%',
height: '13%',
backgroundImage : '/images/btn_login_common_normal.png',
backgroundSelectedImage: '/images/btn_login_common_pressed.png'
}
"#english_text": {
color: '#008c99',
height: '100%',
highlightedColor: '#FFFFFF'
}
----------------.xml文件----------------
<Alloy>
<Window class="container" id = "win">
<ImageView image="/images/selectlanguage_bg.png">
<ImageView id="select_language_pannel">
<Label id = "language_label"></Label>
<Button id = "arabic_button" onClick="onClickArabic" onFocus="onFocusArabic" >
<Label id = "arabic_text" zIndex="100">عـربـي</Label>
</Button>
<Button id = "english_button" onClick="onClickEnglish" onFocus="onFocusEnglish">
<Label id = "english_text" zIndex="100">ENGLISH</Label>
</Button>
</ImageView>
</ImageView>
</Window>
</Alloy>
最佳答案
您正在嵌套不应嵌套的元素。正如您在其他问题中所解释的那样,button
不能嵌套 label
。
当然,ImageViews
也不应该有嵌套元素。
相反,您应该使用 tss
将元素放置在彼此之上。
您的 XML 应如下所示:
<Alloy>
<Window class="container" id = "win">
<ImageView image="/images/selectlanguage_bg.png" />
<ImageView id="select_language_pannel" />
<Label id = "language_label"></Label>
<Button id = "arabic_button" onClick="onClickArabic" onFocus="onFocusArabic" ></Button>
<Button id = "english_button" onClick="onClickEnglish" onFocus="onFocusEnglish"></Button>
</Window>
</Alloy>
当此 XML 就位时,使用 tss 和 zIndex(如果需要)将元素相互定位。
关于android - Titanium 的 Android 模拟器上未显示子 ImageView 、标签和按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34116930/