点击here!查看nexus 5和galaxy core拍摄的屏幕截图... 在Galaxy核心中,一切看起来都不错,但在nexus 5中,由于屏幕尺寸不同,小部件会向左移动......我已经设置了
<property name="ti.ui.defaultunit" type="string">dp</property>
在我的tiapp.xml中
我的xml文件如下......
<Alloy>
<Window id='PreferenceScreen' >
<Button id='button_save' title="Save"/>
<Label id='label_my_project' >My project</Label>
<Label id='label_select_city' >
</Label>
<Label id='label_select_locality' >
</Label>
</Window>
</Alloy>
----我的tss文件----
'#label_my_project': {
top: '88',
left: '20',
width: '280',
backgroundColor: '#00aac1',
color: '#ffffff',
text: 'My Project',
textAlign: 'center',
font: {
fontSize: '25sp'
}
},
'#label_select_city[platform=android]': {
hintText: 'Select City'
},
'#label_select_city': {
top: '143',
left: '40',
width: '240',
font: {
fontSize: '20sp'
}
},
'#label_select_locality[platform=android]': {
hintText: 'Select Locality'
},
'#label_select_locality': {
top: '214',
left: '40',
width: '240',
font: {
fontSize: '20dpsp'
}
},
'#button_save': {
top: '293',
left: '58',
width: '200',
borderWidth: 1,
borderRadius: 5,
borderColor: '#fff',
backgroundColor: '#00aac1',
backgroundSelectedColor: '#fff',
color: '#ffffff',
selectedColor: '#00aac1',
textAlign: 'center',
font: {
fontSize: '20sp'
}
},
'#PreferenceScreen[platform=android]': {
fullscreen: false
},
'#PreferenceScreen': {
top: '0',
left: '0',
backgroundColor: '#00aac1',
navGroup: ''
},
我也试过%但结果相同
请帮助,因为我已经被困了两天,仍然没有解决方案...
答案 0 :(得分:0)
你想把所有元素集中在一起吗? 只需使用
width:'auto'
在所有标签上并制作PreferenceScreen
Ti.UI.FILL
试试这段代码:
查看:
<Alloy>
<Window id='PreferenceScreen' >
<View id='container'>
<Label id='label_my_project' >My project</Label>
<Label id='label_select_city' >
</Label>
<Label id='label_select_locality' >
</Label>
<Button id='button_save' title="Save"/>
</View>
</Window>
</Alloy>
TSS:
'#label_my_project': {
//top: '88',
//left: '20',
width: '280',
backgroundColor: '#00aac1',
color: '#ffffff',
text: 'My Project',
textAlign: 'center',
font: {
fontSize: '25sp'
}
},
'#label_select_city[platform=android]': {
hintText: 'Select City'
},
'#label_select_city': {
top: '40dp',
//left: '40',
width: '240',
backgroundColor:'white',
font: {
fontSize: '20sp'
}
},
'#label_select_locality[platform=android]': {
hintText: 'Select Locality'
},
'#label_select_locality': {
top: '40dp',
//left: '40',
width: '240',
backgroundColor:'white',
font: {
fontSize: '20dpsp'
}
},
'#button_save': {
//left: '58',
top:'40dp',
width: '200',
borderWidth: 1,
borderRadius: 5,
borderColor: '#fff',
backgroundColor: '#00aac1',
backgroundSelectedColor: '#fff',
color: '#ffffff',
selectedColor: '#00aac1',
textAlign: 'center',
font: {
fontSize: '20sp'
}
},
'#PreferenceScreen[platform=android]': {
fullscreen: false
},
'#PreferenceScreen': {
top: '0',
left: '0',
width:Ti.UI.fill,
height:Ti.UI.FILL,
backgroundColor: '#00aac1',
navGroup: ''
},
"#container":{
layout:'vertical',
height:Ti.UI.SIZE,
}