2015-12-06 53 views
2

我正在開發使用Titanium SDK的多平臺應用程序。 然後,此代碼在iOS上運行良好,但無法在android上運行。 我在這裏編寫.tss和.xml代碼。子圖像,標籤和按鈕不顯示在Android模擬器上的鈦

-----------------。tss file -------------------------

".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> 

回答

1

您嵌套的元素不應該嵌套。至於你的其他問題解釋的那樣,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位置的元素。

+1

Rene是對的。在iOS上可以在按鈕內放置標籤或活動指示器。 在Android上這不起作用。我建議你改變ImageView爲一個簡單的視圖,而不是「圖像」使用「backgroundImage」 –

相關問題