2012-03-12 1 views
0

私はPhoneGapのnoobです。私はAndroidアプリをやろうとしています。(Noob)(PhoneGap)同じ解像度をどうやって保ちますか?

私のアプリが正常に動作しますが、解像度が非常に「ハイ」である

私は問題を解決するためにウェブにいくつかのJavaコードを見つけましたが、it'sは、最初の画面だけで動作します。

これは、デJavaコードです:

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //setContentView(R.layout.main); 
    super.loadUrl("file:///android_asset/www/index.html"); 
    this.appView.addJavascriptInterface(this, "android"); 
    this.appView.setInitialScale(0); 


    //Obtenemos el tamaño de la pantalla 
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
    int width = display.getWidth(); 
    int height = display.getHeight(); 

    // double globalScale = Math.ceil((width/orig_app_W) * 100); 
    //ESTA INSTRUCCION ES LA QUE REALMENTE HACE EL REESCALADO 
    double globalScale = Math.ceil((width/orig_app_W) * 70); 


    //Unas cuantas trazas para comprobar que vamos bien ;-) 
    Log.v("ORIG_APP_W", " = " + orig_app_W); 
    Log.v("ORIG_APP_H", " = " + orig_app_H); 
    Log.v("width", " = " + width); 
    Log.v("this.appView.getMeasuredHeight()", " = " + height); 
    Log.v("globalScale", " = " + globalScale); 
    Log.v("this.appView.getScale()", "index=" + this.appView.getScale()); 

    // Establecemos algunos parametros para el web view 
    this.appView.getSettings().setBuiltInZoomControls(false); 
    this.appView.getSettings().setSupportZoom(false); 
    //this.appView.getSettings().setGeolocationEnabled(true); 
    this.appView.getSettings().setLightTouchEnabled(true); 
    this.appView.getSettings().setRenderPriority(RenderPriority.HIGH); 

    this.appView.getSettings().setSupportZoom(true); //Modify this 
    //this.appView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);//Add this 

    // Establecemos la escala 
    this.appView.setInitialScale((int)globalScale);   


} 

そして、これは別の画面(HTML)を呼び出す方法です:

<a href="categorias.html" target="_top"> 

私はこの問題について、いくつかの方向性を必要とします。

ありがとうございます!

答えて

0

あなたのすべてのHTMLファイルで使用これを

<meta name="viewport" content="width=device-width; user-scalable=no" /> 

また、新しいHTMLの使用にナビゲートするには、この

navigator.app.loadUrl("file:///android_asset/www/something.html"); 
関連する問題