Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LWUIT list scroll issue

Tags:

java-me

lwuit

I have a list on LWUIT form. I want to add background image to this form. I try using the following piece of code. The image is being set in background but the list distorts while scrolling.

    categoryList=new List(categories.categoryVector);

    categoryList.setListCellRenderer(new CategoryListCellRenderer());

    Image img=parentMIDlet.constants.getBgImage();

    //img=img.scaled(this.getPreferredW(), this.getPreferredH());
    getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED);

    getStyle().setBackgroundAlignment(Style.BACKGROUND_IMAGE_ALIGN_CENTER);

    getStyle().setBgImage(img);

    //getStyle().setBgPainter(new ImagePainter(img));



    addComponent(BorderLayout.CENTER,categoryList);

    categoryList.isScrollableY();

    categoryList.setFixedSelection(List.FIXED_NONE);

    categoryList.addActionListener(new CategoryListActionListener(mainMIDlet,categoryList));
like image 775
Chetan Khilare Avatar asked May 09 '26 02:05

Chetan Khilare


1 Answers

If you are using 1.5 or newer you should use:

getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED_CENTER);

Make sure the list bg transparency is set to 0 for both selected and unselected styles. Make sure the parent form is set to scrollable false.

like image 85
Shai Almog Avatar answered May 13 '26 02:05

Shai Almog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!