android - Titanium 的 Android 模拟器上未显示子 ImageView 、标签和按钮

标签 android imageview label titanium

我正在使用 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/

相关文章:

android - 十大最致命的权限是什么?

android - 如何在android中一次缩放多个图像?

android - 如何在ImageView中设置图片?

javascript - 使用 React-Three-Renderer 的 Sprite 标签(包括 MVCE)

extjs - 如何在 extjs 中的单个文本字段标签上设置标签宽度?

android - 在 Android 上使用 GL_OES_get_program_binary(编译着色器)

android - 如何解决 Xamarin Forms 中的部署错误?

javascript - 如何删除通过 Highcharts 中的 Chart.renderer 添加的文本

android - 我可以调试不是我创建的 .apk 吗

android - Titanium appcelerator ImageView 加载事件监听器不适用于 android