0

I am adding 3 images in 3 BitmapFields in a HFM. It scrolls horizontally with trackwheel but I want the images to auto-scroll like marquee text. I got the thread to display scroll text like marquee but how to replace that with images?

Community
  • 1
  • 1
Shreyas
  • 209
  • 1
  • 7
  • 16

2 Answers2

0

Say your TimerTask increment the scrollAmount named int currentScroll

You have to handle the image in the paint method of a Custom Field. Here an exemple for one image to scroll (if the image is larger that your screen):

Bitmap bmp = this.getBitmap1();
int width = bmp .getWidth();
graphics.drawBitmap(0, 0, width , bmp.getHeight(), bmp, currentScroll, 0)
Benoit
  • 1,922
  • 16
  • 25
  • Thanks Hithredin, I am doing it. Do I need to call my `CustomBitmapField extends BitmapField` for 3 times for 3 images unlike `MarqueeLabel extends LabelField` is called once? `MarqueeLabel` contains the whole label so its drawn in one call to `super()`, but here I have 3 bitmaps. If I need to call it 1 time only then how to call `super(bitmap)`? (Please refer the above link for scrolling marquee text). – Shreyas Aug 29 '12 at 10:42
  • Hey, its scrolling but some exceptions in `onFocus()` and `onUnfocus()`. I am calling `invalidate()` from there to change some border effects while focussed. am I doing right? Please correct me. – Shreyas Aug 29 '12 at 11:45
  • How do you add border? In this state of customisation, i'd recommend to draw your border in the paint method (graphics.drawFillREct something like that) depending if you have focus or not. – Benoit Aug 29 '12 at 12:47
  • I am setting the border in `paint()` and calling `invalidate()` from `onFocus()` and `onUnFocus()`. Thus calling `paint()` 2 times. I think that is giving exception when `onFocus()` gets called. – Shreyas Aug 31 '12 at 17:58
0
BitmapField imageField = new BitmapField(Bitmap.getBitmapResource("sync.png"),
                Field.FOCUSABLE);

Border imageFieldBorder = BorderFactory.createBevelBorder(edges, new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK,Color.BLACK), new XYEdges(Color.WHITESMOKE, Color.WHITESMOKE,Color.WHITESMOKE, Color.WHITESMOKE));


imageField.setBorder(imageFieldBorder);

You can change the color's of border also

Govindarao Kondala
  • 2,862
  • 17
  • 27
Nitesh
  • 34
  • 7