Fitting image from higher resolution to screen.

74 views
Skip to first unread message

jose.p...@gmail.com

unread,
Nov 6, 2013, 3:33:54 AM11/6/13
to codenameone...@googlegroups.com
I am trying to do a Splash but I use larger images with higher resolution, the thing is that I don´t know how can I resize this image to fit screen 

Shai Almog

unread,
Nov 6, 2013, 1:13:32 PM11/6/13
to codenameone...@googlegroups.com, jose.p...@gmail.com
Place a container in the center of the splash screen (make the splash screen a border layout).
Set its UIID to SplashImage.
Style SplashImage in the designer to have the bgImage and the right scaled mode (Scaled, Scale to fit or Scale to fill).

Jose Pina

unread,
Nov 7, 2013, 2:46:48 AM11/7/13
to Shai Almog, codenameone...@googlegroups.com
thank you,but I was actually working the ui throught code. Another issue I have is that I created a Label Object and I assigned a Image to the Icon, but when I put another Label with Image on top of the first one, I see a White Background, and my PNG comes with transparent BG.



My code so far



//Crear Pantalla
pantalla = new Pantalla();
pantalla.setLayout(new BorderLayout());
pantalla.setScrollable(false);

Log.p("Creando logo ministerio");
Label logo_label = new Label(res.getImage("logo_ministerio.png").scaledWidth(Pantalla.MATCH_PARENT));

Log.p("Agregar logo");
Container objects = new Container(new LayeredLayout());
objects.setWidth(Pantalla.MATCH_PARENT);
Label logo_dgt = new Label(res.getImage("logosinnombre.png").scaledWidth(Pantalla.MATCH_PARENT));


Log.p("Agregar letras");
Container letters = new Container(new BoxLayout(BoxLayout.X_AXIS));
Label d = new Label(res.getImage("d.png"));
Label g = new Label(res.getImage("g.png"));
Label t = new Label(res.getImage("t.png"));
letters.addComponent(d);
letters.addComponent(g);
letters.addComponent(t);


objects.addComponent(logo_dgt);
//objects.addComponent(letters);
Log.p("Agregar componente");
//Agregar
pantalla.addComponent(BorderLayout.NORTH, logo_label);
pantalla.addComponent(BorderLayout.CENTER, objects);
pantalla.setShouldCalcPreferredSize(true);
pantalla.show();



Where Pantalla object is a Form an extended version of Form


2013/11/6 Shai Almog <shai....@gmail.com>

Jose Pina

unread,
Nov 7, 2013, 2:48:44 AM11/7/13
to Shai Almog, codenameone...@googlegroups.com
I forgot to say this is the messy part 

objects.addComponent(logo_dgt);
//objects.addComponent(letters);


The logo and its letters are in different PNG's but when I try to add the logo as a Base and then its letters, each letter comes with a white background.





2013/11/7 Jose Pina <jose.p...@gmail.com>

Shai Almog

unread,
Nov 7, 2013, 1:39:45 PM11/7/13
to codenameone...@googlegroups.com, Shai Almog, jose.p...@gmail.com
You can do this in code or the GUI builder, the style aspect has nothing to do with the GUI builder just the theme.
If you want to do it manually just invoke the appropriate methods on getUnselectedStyle() to do the same.

I'm guessing the reason the letters have a white background is that the theme has bg transpaency of 255 instead of 0 for these component types. You can either set that or again use the style object in code.
I suggest watching the How Do I video on themeing.
Reply all
Reply to author
Forward
0 new messages