background image scroll disable in Main field manager in blackberry

帅比萌擦擦* 提交于 2019-12-11 18:10:36

问题


In my application there is one MainScreen .This screen contain lots of Vertical and Horizontal field manager and all content display successfully with scroll .

This is my main VerticalFieldmanager code .

vfm_Main = new VerticalFieldManager()
    {
            public void paint(Graphics g)
            {
                g.setColor(Color.WHITE);
                g.drawBitmap(0,0,mybackgroundImage.getWidth(),mybackgroundImage.getHeight(),mybackgroundImage,0,0);
                                    super.paint(g);
            }
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.sublayout(Display.getWidth(),Display.getHeight());
                setExtent(Display.getWidth(),Display.getHeight());
            }
    };

there is one background image draw for this screen . When i scroll this screen to see the full content of this screen my Background image also scroll with the content ..for that reason background image looks so blury and it is repeat at the bottom of the screen .

i want to scroll only the content of that screen .so how to implement this ..?

i had try alot but not getting any suggetion and hits to prevent that ? if any one facing this problem or have any idea please help me ...

Thanks in Advance !!!


回答1:


You have to do like this:

vfm_Main = new VerticalFieldManager()
{
            public void paint(Graphics g)
            {
                g.setColor(Color.WHITE);
                g.drawBitmap(0,0,mybackgroundImage.getWidth(),mybackgroundImage.getHeight(),mybackgroundImage,0,0);
                super.paint(g);
            }
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                    super.sublayout(Display.getWidth(),Display.getHeight());
                    setExtent(Display.getWidth(),Display.getHeight());
            }
};

subver=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR)
{
        protected void sublayout(int maxWidth, int maxHeight) 
        {
                 super.sublayout(Display.getWidth(),Display.getHeight()-3);//here we scroll the inner vertical
                 setExtent(Display.getWidth(),Display.getHeight()-3);
        }
 }
 //Write all the code here;
 subver.setpadding(1,0,0,0);
 vfm_main.add(subver);
 add(vfm_Main);

Like this Image:

Enough;




回答2:


I too faced the same issue once. I fixed it by using 2 field managers like this.

VerticalFieldManager mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )
    {

        public void paint(Graphics graphics)
        {
            graphics.clear();
            graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backgroundBitmap, 0, 0);                       
            super.paint(graphics);
        }            
    };
  //this manager is used for adding the componentes
    VerticalFieldManager subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR )
    {
        protected void sublayout( int maxWidth, int maxHeight )
        {
            int displayWidth = Display.getWidth();
            int displayHeight = Display.getHeight();

            super.sublayout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }
    };


来源:https://stackoverflow.com/questions/8165772/background-image-scroll-disable-in-main-field-manager-in-blackberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!