2012-01-12 61 views
2

私は自分のBlackBerryアプリのスプラッシュ画面を作成しています。現在、画像は、私がテストしているすべてのシミュレータに正しく配置されていません。 すべてのデバイスサイズに適合するように、スプラッシュ画面のイメージのサイズはどのくらいにする必要がありますか?スプラッシュ画面の画像サイズ

+1

サポートしたいデバイスをリストし、その画面のディメンションを一覧表示します。そして、次元(すべての画面幅の最小幅、すべての画面高さの最小高さ)を持つ画像を作成します。次に、縦と横を中央に置くことができます。また、 'Bitmap.scaleInto(params)'を使用して、任意のイメージを使用し、実行時にそれらのサイズを変更することができます。 – Rupak

答えて

4

主要部分は、のUIApplicationを拡張起動クラスを作成する、です。

これはStartUp.java

public class StartUp extends UiApplication 
{ 
public static void main(String[]args) 
{ 
    StartUp start=new StartUp(); 
    start.enterEventDispatcher(); 
} 
public StartUp() 
{ 
    this.pushScreen(new SplashScreen()); 
    invokeLater(new Runnable() 
    { 
     public void run() 
     { 
      try 
      { 
       Thread.sleep(2000);// Sleeps it for few seconds 
       UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); 
       pushScreen(new LoadingScreen()); 
      } 
      catch (Exception e) 
      { 
       exceptionHandling(e.getMessage()); 
      } 
     } 
    }); 

} 

public static void exceptionHandling(final String exception) 
{ 
    UiApplication.getUiApplication().invokeLater(new Runnable() 
    {  
     public void run() 
     { 
      Dialog.alert(exception); 
     } 
    }); 
} 
} 

SplashScreen.java

public class SplashScreen extends MainScreen 
{ 
Bitmap bitmap=Bitmap.getBitmapResource("loading-screen.png");//This is my company logo; 
BitmapField loadingImage=new BitmapField(bitmap); 
public SplashScreen() 
{ 
    createGUI(); 
} 

private void createGUI() 
{ 
    try 
    { 
     VerticalFieldManager vertical=new VerticalFieldManager() 
     { 
      protected void paint(Graphics g) 
      { 
       g.drawBitmap(0, 0,Display.getWidth(),Display.getHeight(), bitmap, 0, 0); 
       super.paint(g); 
      } 
      protected void sublayout(int maxWidth, int maxHeight) 
      { 
       super.sublayout(Display.getWidth(),Display.getHeight()); 
       setExtent(Display.getWidth(),Display.getHeight()); 
      } 
     }; 

    //   Nothing to write; 

     add(vertical); 
    } 
    catch (Exception e) 
    { 
     StartUp.exceptionHandling(e.getMessage()); 
    } 
} 
} 

とあなたのFirstScreen.java

public class FirstScreen extends MainScreen 
{ 
VerticalFieldManager vertical; 

public FirstScreen() 
{    
    createGUI(); 
} 

private void createGUI() 
{ 
    setTitle("Loading Screen"); 
    vertical=new VerticalFieldManager() 
    { 
     protected void sublayout(int maxWidth, int maxHeight) 
     { 
      super.sublayout(Display.getWidth(),Display.getHeight()); 
      setExtent(Display.getWidth(),Display.getHeight()); 
     } 
    }; 
    add(vertical); 
} 

public boolean onMenu(int instance) 
{ 
    return true; 
} 
} 
です

これを試してみてください。

1

400X400のような画像を撮り、その画像をプロジェクトのresフォルダに入れてください。

次に スプラッシュ画面のクラスファイルでは、デバイスの高さを&の幅で画像のサイズを変更できます。

Bitmap splashImage = Bitmap.getBitmapResource("Splash.png");//your splash screen's name with it's extension if it is PNG then .png & if JPG then .jpg 
    Bitmap scale = new Bitmap(Display.getWidth(),Display.getHeight()); 
    splashImage.scaleInto(scale, Bitmap.FILTER_BILINEAR); 

    VerticalFieldManager mainManager = new VerticalFieldManager(
     VerticalFieldManager.NO_VERTICAL_SCROLL 
       | VerticalFieldManager.USE_ALL_HEIGHT 
       | VerticalFieldManager.USE_ALL_WIDTH) { 
     public void paint(Graphics g) { 
      g.drawBitmap(0, 0, scale.getWidth(), scale.getHeight(), scale, 0, 0); 
      super.paint(g); 
     } 
     }; 
    add(mainManager); 
    //This vertical field can set your converted image as screen background 
    // Note :- you must have to extends FullScreen insteadOf MainScreen 
関連する問題