0
votes

Click here! to view the screen shot taken on nexus 5 and galaxy core... In galaxy core,everything appears good but in nexus 5 the widgets get shifted to the left due to different screen size... I have set

<property name="ti.ui.defaultunit" type="string">dp</property> 

in my tiapp.xml

My xml file is as follows...

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

----my tss file----

'#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: ''
},

I have also tried with % but same result

Please help as i have been stuck since past two days and still no solution...

1

1 Answers

0
votes

Do you want to center all elements ? Just use

width:'auto' 

on all labels and make the PreferenceScreen

Ti.UI.FILL

Try this code:

VIEW:

<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,
}