开发者

Not showing Transparent background?

Hi developers I have a screen with transparent background(bitmap). I have a list field placed on top of it, but the issue is the transparent background is not showing the previous screen, instead it shows white screen with listfield.

public class IndexScreen extends MainScreen implements ListFieldCallback {

    private Vector rows;
    ListField listItems;
    int listItem;
    int listFieldIndex = -1;
    TableRowManager ro开发者_StackOverfloww;
     Bitmap indexBox = Bitmap.getBitmapResource("res/screens/Index_Box.png");

    public IndexScreen() {
        listItems = new ListField() {
        listItems.setRowHeight(20);
        listItems.setCallback(this);
        rows = new Vector();

        listItems.setSize(rows.size());
        _listVfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL) {

            public void paint(Graphics g) {
                g.drawBitmap(0, 0, UIinitialize.screenWidth,
                            UIinitialize.screenHeight, indexBox, 0, 0);

                super.paint(g);
            }

            protected boolean navigationMovement(int dx, int dy, int status,
                    int time) {
                return super.navigationMovement(dx, dy, status, time);
            }
            protected void sublayout(int maxWidth, int maxHeight) {

                layoutChild(listItems, maxWidth, maxHeight);
                setPositionChild(listItems, 5, 0);       
                    setExtent(maxWidth, 255);
            }
        };
        _listVfm.add(listItems);
        add(_listVfm);

        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                listItems.invalidate();
            }
        }, 500, true);

    }

    public void drawListRow(ListField listField, Graphics graphics, int index,
            int y, int width) {
        TableRowManager rowManager = (TableRowManager) rows.elementAt(index);
        rowManager.drawRow(graphics, 0, y, width, listItems.getRowHeight());
    }

    class TableRowManager extends Manager {
        public TableRowManager() {
            super(0);
        }

        public void drawRow(Graphics g, int x, int y, int width, int height) {
            layout(width, 250);
            setPosition(x, y);
            g.pushRegion(getExtent());
            subpaint(g);
            g.setColor(0x00CACACA);     
            g.popContext();
        }
        protected void sublayout(int width, int height) {
            int preferredWidth = getPreferredWidth();
            Field field = getField(0);
            layoutChild(field, preferredWidth, height);
            setPositionChild(field, 0, 0);
            setExtent(width, height);

        }
        public int getPreferredWidth() {
            return listItems.getWidth();
        }
        public int getPreferredHeight() {
            return listItems.getRowHeight();
        }
    }

    public Object get(ListField listField, int index) {
        return null;
    }
    public int getPreferredWidth(ListField listField) {
        return 0;
    }
    public int indexOfList(ListField listField, String prefix, int start) {
        return 0;
    }
}

The above code is the part of the code that I am using.How can I implement to view the transparent background.Can anybody please help me.Thanks.


MainScreen includes its own non-transparent background. You'll have to extend Screen if you want to have a transparent/translucent background.


Another option, which I've used in my apps, is using FullScreen instead of MainScreen. FullScreen allows transparent backgrounds. If you're using setStatus or setTitle you'll have to find another method of displaying that data, but otherwise it's very similar.

From your code, though, extending Screen instead of MainScreen would likely by more appropriate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜