Splash screen image size

*爱你&永不变心* 提交于 2019-12-10 11:05:37

问题


I am creating a splash screen for my BlackBerry app. Right now the image is not properly placed in all the simulators on which I am testing. What should be the size of my image for the splash screen, so that it fits in all the device sizes?


回答1:


The main part is, creating Startup Class which extends UiApplication.

This is the 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);
        }
    });
}
}

and the 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());
    }
}
}

and your 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;
}
}

Try this you can get.




回答2:


Just take any image like 400X400 and put that image to your project's res folder.

Then in splash screen class file you can resize the image with device's height & width.

    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


来源:https://stackoverflow.com/questions/8831430/splash-screen-image-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!