Adattare visiualizzazione contenuti app per tutti i device

di il
2 risposte

Adattare visiualizzazione contenuti app per tutti i device

Ciao devo fare un codice intelligente a partire da un codice stupido, e ho bisogno di aiuto che non ho una laurea in informatica forse non ce la faccio,

praticamente ho fatto una app per android con flex air quindi il codice in questione è actionscript ma a me serve un aiuto nella logica dello script più che per as

praticamente con actionscript mi devo caricare con lo StageWebView(); l'html di una pagina web lo stagewebview quindi è il contenitore che ha delle coordinate x e y
e siccome cè una testata nella schermata della app con il logo dell'azienda devo fare in modo che lo stagewebview non copra il logo perchè se metto un y poi in base alla risoluzione del device e alle sue dimensioni finisce che i contenuti sono troppo in basso o troppo in alto coprendo il logo

il codice è stupido ma funziona almeno parzialmente, il problema è che ci sono una trentina di device in cui questo codice dove funziona ma ce ne sempre qualcuno che non è compreso nello script e percio per quello non funziona

praticamente io ho dei dati per cui ad es con una densita di 168 e un'altezza di 736 la y va piazzata a 90 e cosi via per tutti i device io devo dedurre una regola in modo da fare un codice che in base a 3 parametri l'altezza la densita la y posso calcolare la y per altezze e densita diverse mi aiutate almeno per impostare la logica poi praticamente questo codice rimane utile per tutte le app fatte con air lo possiamo condividere se funziona, vi ringrazio tanto se mi aiutate
if(stage.stageHeight==736 && Capabilities.screenDPI==168){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						//motorola droid
						if(stage.stageHeight==736 && Capabilities.screenDPI==265){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						//nexus
						if(stage.stageHeight==736 && Capabilities.screenDPI==252){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						//droid x
						if(stage.stageHeight==736 && Capabilities.screenDPI==228){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==736 && Capabilities.screenDPI==150){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==736 && Capabilities.screenDPI==233){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==480 && Capabilities.screenDPI==144 ){
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);
						}
						if(stage.stageHeight==736 && Capabilities.screenDPI==217){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==736 && Capabilities.screenDPI==235){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==480 && Capabilities.screenDPI==160 ){
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);
						}
						if(stage.stageHeight!=736 && Capabilities.screenDPI==233){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==762 && Capabilities.screenDPI==252){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==752 && Capabilities.screenDPI==262){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==181){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==775 && Capabilities.screenDPI==235){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==775 && Capabilities.screenDPI==216){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==180){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight!=775 && Capabilities.screenDPI==233){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==775 && Capabilities.screenDPI==217){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==922 && Capabilities.screenDPI==256){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==762 && Capabilities.screenDPI==259){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==999 && Capabilities.screenDPI==170){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==762 && Capabilities.screenDPI==246){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==170){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==762 && Capabilities.screenDPI==245){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==775 && Capabilities.screenDPI==215){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==301 && Capabilities.screenDPI==125){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==781 && Capabilities.screenDPI==133){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==502 && Capabilities.screenDPI==275){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==829 && Capabilities.screenDPI==165){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==816 && Capabilities.screenDPI==265){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==922 && Capabilities.screenDPI==275){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==144){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==816 && Capabilities.screenDPI==228){	
							stageWebView.viewPort = new Rectangle(0,125,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==272 && Capabilities.screenDPI==150){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==301 && Capabilities.screenDPI==143){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==165){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==455 && Capabilities.screenDPI==165){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==999 && Capabilities.screenDPI==169){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==1232 && Capabilities.screenDPI==170){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==480 && Capabilities.screenDPI==165){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
						if(stage.stageHeight==1024 && Capabilities.screenDPI==160){	
							stageWebView.viewPort = new Rectangle(0,90,stage.stageWidth,stage.stageHeight);	
						}
					}

2 Risposte

  • Re: Adattare visiualizzazione contenuti app per tutti i device

    Be quel codice non è molto furbo
    Da quello che scrivi mi sembra di capire che devi trovare una formula che metta in relazione i 3 paramentri con il risultato che vuoi attenere..

    perchè come eposizione TOP vedo solo valori: 90 e 125?
  • Re: Adattare visiualizzazione contenuti app per tutti i device

    Si in questo caso è una immagine di 180px che poi nella app riesce ad occupare l'altezza fino a y= 90 o a y=125 o a Y=180 in base ai 2 parametri altezza dello screen e densità

    si ho notato che ci devessere una regola che lo piazza fino a 90 o 125 o 180 anche se i 2 parametri sono svariati quindi io dovrei mettere tutti questi numeri in una specie di funzione matematica per trovare la formula per cui li piazza in questi 3 valori e avere quindi un algoritmo che in base a nuove possibili altezze dello screen e densita mi trovo la y automaticamente senza dovere inserire i due parametri ad uno ad uno per ogni device visto che ogni giorno c'è un device nuovo e diverso

    (io ho inserito praticamente quasi tutti gli android esistenti mi mancano quelli nuovi)

    vi ringrazio se mi aiutate
Devi accedere o registrarti per scrivere nel forum
2 risposte