vectoriales vectorial tipos mapa imagenes dibujo botones animaciones user-interface blackberry scroll background

user interface - vectorial - BlackBerry: el mapa de bits de fondo no se ajusta a la página de desplazamiento



mapa de bits de flash (2)

La respuesta de Max Gontar es un asesino de baterías;

protected void paintBackground(Graphics graphics) { paintBackgroundBitmap(graphics); invalidate(); }

Como invalidate () dará como resultado una llamada a paintBackground (Graphics).

Tengo un mapa de bits de fondo en la pantalla de mi aplicación Blackberry. La pantalla tiene el desplazamiento activado ya que debo tener un desplazamiento. El problema que estoy enfrentando es que, cuando me desplazo hacia abajo en la página, el mapa de bits de fondo no se ajusta a la página desplazada, sino que muestra simplemente un fondo blanco. ¿Necesitamos dibujar el mapa de bits de fondo para cada página de desplazamiento?

Mi tamaño de mapa de bits es: 360 * 480

El código actualizado es:

class BGVerticalFieldManager extends VerticalFieldManager { Bitmap mBgBitmap = null; int mBgWidth = -1; int mBgHeight = -1; int mBgX = -1; int mBgY = -1; public BGVerticalFieldManager(Bitmap background) { super(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL | VERTICAL_SCROLLBAR); mBgBitmap = background; mBgWidth = mBgBitmap.getWidth(); mBgHeight = mBgBitmap.getHeight(); mBgX = (Display.getWidth() - mBgWidth) >> 1; mBgY = (Display.getHeight() - mBgHeight) >> 1; } protected void paintBackground(Graphics graphics) { paintBackgroundBitmap(graphics); invalidate(); } /*private void paintBackgroundBitmap(Graphics graphics) { if (null != mBgBitmap) { int x = mBgX + ((MainScreen)getScreen()) .getMainManager().getHorizontalScroll(); int y = mBgY + ((MainScreen)getScreen()) .getMainManager().getVerticalScroll(); graphics.drawBitmap(x, y, mBgWidth, mBgHeight, mBgBitmap, 0, 0); } } */ private void paintBackgroundBitmap(Graphics graphics) { if (null != mBgBitmap) { int x = mBgX + getHorizontalScroll(); int y = mBgY + getVerticalScroll(); graphics.drawBitmap(x, y, mBgWidth, mBgHeight, mBgBitmap, 0, 0); } }

}

LLAMANDO AL FONDO ARRIBA ANTERIOR EL CÓDIGO DE BITMAP DESDE EL OTRO ARCHIVO A CONTINUACIÓN:

public MyFirstScreen ( String label, int screenState, int selectedObj, boolean bUI ) { super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR); // I must need it ... appTitle = label; setTitle(appTitle); background = Bitmap.getBitmapResource ("HomeBack.png"); add(_container = new BGVerticalFieldManager(background)); .............................. .............................. ..............................

}


Para obtener la posición de desplazamiento real, puede utilizar getVerticalScroll () :

class BGVerticalFieldManager extends VerticalFieldManager { Bitmap mBgBitmap = null; int mBgWidth = -1; int mBgHeight = -1; int mBgX = -1; int mBgY = -1; public BGVerticalFieldManager(Bitmap background) { super(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL | VERTICAL_SCROLLBAR); mBgBitmap = background; mBgWidth = mBgBitmap.getWidth(); mBgHeight = mBgBitmap.getHeight(); mBgX = (Display.getWidth() - mBgWidth) >> 1; mBgY = (Display.getHeight() - mBgHeight) >> 1; } protected void paintBackground(Graphics graphics) { paintBackgroundBitmap(graphics); invalidate(); } private void paintBackgroundBitmap(Graphics graphics) { if (null != mBgBitmap) { int x = mBgX + getHorizontalScroll(); int y = mBgY + getVerticalScroll(); graphics.drawBitmap(x, y, mBgWidth, mBgHeight, mBgBitmap, 0, 0); } } }

texto alternativo http://img693.imageshack.us/img693/6245/9000.jpg
Muestra de uso:

class Scr extends MainScreen { private BGVerticalFieldManager mContainer; public Scr() { super(NO_VERTICAL_SCROLL); setTitle("Screen Title"); Bitmap bitmap = Bitmap.getBitmapResource("BoldOEM.jpg"); add(mContainer = new BGVerticalFieldManager(bitmap)); for (int i = 0; i < 100; i++) { mContainer.add(new LabelField("List item #" + String.valueOf(i))); mContainer.add(new NullField(FOCUSABLE)); } } }