Faced with centered Background Image

I have the code that I found always give me a background focused on a screen image.  It is based on the ideas presented here:

http://supportforums.BlackBerry.com/T5/Java-development/MainScreen-explained/Ta-p/606644

However, the code does not, at least not for me.

I tried other variations as well, as the addition of another not VFM of scrolling, then adding data scrolling to the optimization of resources, but even this indirection suffers from the same problem.  Have two screenshots to show, the 'exclamation' should be at the centre according to me!

Code follows.

To illustrate the problem, just space out the field change with "entry" for more complete screen.  Then the same thing to one below the Bitmap and then scroll and down using the trackpad.  I suspect that you will see the problem.

I saw this on OS 6.0 and 7.0 OS simulators.  Not tested on OS 5.0 and tested only on touchscreen devices.  I'll do some more tests later.

Someone at - it suggestions on the subject of how we get the "centered" background Bitmap actually stay in the Center will still let me add lines to my editfields and scroll using the trackpad?

Net.rim.device.api.system import. *;
Net.rim.device.api.ui import. *;
Net.rim.device.api.ui.component import. *;
Net.rim.device.api.ui.container import. *;

/**
* A screen class to test background bitmap images.
*/
SerializableAttribute public class BackgroundImageScreen extends screen
{
private int backgroundColor = 0x00FF0000;
private bitmap _backgroundBitmap = Bitmap.getPredefinedBitmap (Bitmap.EXCLAMATION);
   
Constructor
public BackgroundImageScreen()
{
Super(Manager.USE_ALL_WIDTH |) Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR);
setTitle (new LabelField ("Background Image Demo"));
VerticalFieldManager backgoundManager = VerticalFieldManager(Manager.USE_ALL_WIDTH | nouveau Manager.USE_ALL_HEIGHT |) Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) {}
{} public void paintBackground (Graphics g)
int currentVackgroundColor = g.getBackgroundColor ();
try {}
g.setBackgroundColor (backgroundColor);
g.Clear ();
} {Finally
g.setBackgroundColor (currentVackgroundColor);
}
int managerWidth = this.getWidth ();
int managerHeight = this.getHeight ();
centerX = int (this.getWidth () - _backgroundBitmap.getWidth (()) 2.
centerY = int (managerHeight - _backgroundBitmap.getHeight ()) 2.
System.out.println ("current position:" + Integer.toString (centerX) + ":" + Integer.toString (centerY) +)
", Far manager:" + Integer.toString (managerWidth) + ":" + Integer.toString (managerHeight) + "."
", Manager virtual:" + Integer.toString (this.getVirtualWidth () + ":" + Integer.toString (this.getVirtualHeight () + "."
", ManagerScroll:" + Integer.toString (this.getHorizontalScroll () + ":" + Integer.toString (this.getVerticalScroll ())); "."
g.drawBitmap (this.getHorizontalScroll () + centerX, this.getVerticalScroll () + centerY, _backgroundBitmap.getWidth (), _backgroundBitmap.getHeight (), _backgroundBitmap, 0, 0);
                   
}
};
backgoundManager.add (new EditField ("scrolling test:", "Enter the text here to scroll"));
backgoundManager.add (new SeparatorField());
backgoundManager.add (new BitmapField (Bitmap.getPredefinedBitmap (Bitmap.QUESTION)));
backgoundManager.add (new SeparatorField());
backgoundManager.add (new EditField ("test an another parchment:", "Enter the text here to scroll"));
This.Add (backgoundManager);

}
}

Ahh, touch screens...

I remember I had to invalidate the Manager paint extra stuff (vertical scroll bar in my case) in scrollChanged() specifically for touchscreen devices. So one thing to try is to implement ScrollChangeListener in your main screen or your added VFM and invalidate the VFM in scrollChanged. This should fix the problem, even if it will be a drop in performance.

I suspect that the touchscreen devices have certain graphic hardware acceleration, which makes them more effective when scrolling but it lacks what BlackBerry stuff framework is not aware (for example your paintBackground according to the positions of scrolling).

I'm curious to know what happens if you use setBackground on a scroll, no Manager and add the scroll with no bottom paint on top of it. setBackground, being a built-in could make better use of their hardware acceleration.

Tags: BlackBerry Developers

Similar Questions

  • Custom with a background image button had a white area around it

    Hello

    I have a screen with a black background and I am trying to add a custom button with a background image on it. But the custom button has a white border around it.

    Is it possible to remove this white border or black?

    Thank you

    Is the custom field button only focusable, or do you see it too when she does not have focus? Try drawFocus() substitution if it is only when he has developed there.

  • How to fade along with a background image.

    Does anyone have a suggestion on how better to fade along with a background image, which left and right side exactly blends in the background. In addition, it should be a very gradual fade.

    My image is a model of 18px 1900px X and it supposed to repeat on the y-axis. I did apply a layer mask, select from the left and the right 250 250px. Then I went to put smoth to 100% and the feather to 100px, and cut the fethers part to see the fade.  It worked well, but you are still able to see the visible lines on each display of color fade. The re is a better way to fade and other image or something else I can try to make the transition to choke?

    Thank you!

    Looks like bands, not feather. try to work in 16-bit...
    / G

  • Menu Bar Spry Widget 2.0 with several background images.

    Hello

    I am quite new to HTML & CSS. I designed a navigation system using Dreamweaver built in the Spry menu bar. When I discovered that it did not work on the mobile platform iOS (iPad), I rebuilt using the 2.0 Bar Menu Spry Widget. After going through the tutorial of David Powers on the subject (here: http://www.adobe.com/devnet/dreamweaver/articles/spry_menu_bar.html ) and tweaking the CSS by trial and error that I'm going to look very nice, but is not quite where I want it to be, and I need help. It is a question of the 3 part (well okay, it's three different questions).

    Here are two links to the work in progress (note: all site links, see the pages still using the older menus built-in spry bar - please ignore them). CSS for the menu is contained in these documents. Each maintains a drop-down list in a slightly different way. Both versions are relevant to questions 2 and 3.

    http://www.mentalwarddesign.NET/Dynamech/about/index.html

    http://www.mentalwarddesign.NET/Dynamech/about/indexV2.html

    1. when a link is set to a menu item that contains a submenu, the submenu drop-down does not work on iOS touchscreen devices (ie the iPad). Main menu link must be removed so that it works correctly. I want a user to be able to click (or tap) on the main menu item and be taken directly to the first page in the submenu. Is there a solution for this?

    2. the first version (/ index.html) has a submenu with a border and demarcation lines. The second version (/ indexV2.html) has no borders/lines, but a RADIUS on the corners. I try to combine these to have the RADIUS and the lines. The borders are controlled by #MenuBar. SubMenu.MenuItem RADIUS is controlled by #MenuBar.SubMenuVisble and #MenuBar.MenuLevel1.SubmenuVisible. The problem I get when you combine the two effects is that borders extend beyond the RADIUS. I tried ' overflow: hidden ' on any combination of the foregoing ID's and the only thing that made him the flyout of sub-sub to appear is prevented. Any thoughts on how I might accomplish this?

    3 here is what is referenced in the subject.  The Menu bar is in a div tag called navMain. The background image in this div is made unique navigation bar image to look like seven tabs. If you look at the indexV2.html link above and go to the 'about' tab you'll see what I'm doing. I need to use a different background image for each tab for consulted/assets /. And of course I don't want the images repeat in the submenus as they do here. But wait, there is more! I also want to create a State "chosen" so that the image on hover shows from any page you are visiting currently - IE if you look at any page in the 'Drawings' submenu (of lets say that you are on the "miscellaneous" page) then the stationary image for "Drawings" is displayed. And if possible, he would suffer to the question I posed in the #1?

    Thanks in advance for helping this newbie. The responces are greatly appreciated.

    Ed

    If the markup of my menu bar is the following

    so I can style each button as follows

    #MenuBar .home. MenuItem, #MenuBar .home. MenuItem. {MenuItemLabel}

    background-color: orange;

    }

    #MenuBar .entertainment. MenuItem, .entertainment #MenuBar. MenuItem. {MenuItemLabel}

    background-color: red;

    }

    #MenuBar .politics. MenuItem, #MenuBar .politics. MenuItem. {MenuItemLabel}

    background-color: white;

    }

    #MenuBar .sports. MenuItem, .sports #MenuBar. MenuItem. {MenuItemLabel}

    background-color: blue;

    color: white;

    }

    GRAMPS

  • How this guy do this with its background images?

    In the following example, the background image stretches to fill your screen in real time (try resizing browser on the fly), but retains its proportions intact throughout. I didn't even know it was doable.

    Can someone tell me how this is done?

    http://www.serialcut.com/

    Click options in the upper left to see other background images in action. The transition effect is not important. I am referring strictly to the properties ' full page + kept proportions "of these environments.

    Is there a tutorial somewhere for that?

    It seems they did a custom jquery plugin.  The problem is that eventually even with their method, the images have a limit.  Their image is 1920 x 1108.  So they made up a 1080 display.  After that the image could not be resized.  But to have the image resized, you must load the large image for all users regardless of their resolution of the screen.

    The following link seems to have a similar distribution of jquery:

    http://johnpatrickgiven.com/jQuery/background-resize/

  • DWCS4 behavior of the effects appear with DIV background image?

    Is it possible to use the effects appear on the background image in a DIV with the command 'OnLoad '. I want my banner to fade in (param) when the page is reached.
    It's the tag with that I want to use the above behavior:
    < div class = "dwBanner" > < / div >

    Thank you very much.
    www.dwdallam.com

    ...

  • How to create a no with scrolling background image

    I searched a lot on the forum and able to paint my background either by overriding methods of painting/paintBackground of the screen or the Manager. But the background is still floating, which means that when the screen scrolls down, the background goes back and white space appears.

    My question is, how do I make the fixed background image?

    Have you checked this post?

    http://supportforums.BlackBerry.com/T5/Java-development/about-background-images-and-layouts/m-p/2442...

    T

  • Please help beginner with CSS background-image

    I use Dreamweaver CS4. I created a site on my computer. D:Data\Local_sites\Gravity_Works. In this directory using Dreamweaver, I created 3 files - css, images and models. In the pictures folder, I have an image - bg_body_winter.jpg. In the Templates folder, I have Gravity-works - Home01.dwt. I have created a new form of the page the template file and named index - test01.html and saved directly in the folder Gravity_Works

    I have this css code in a css in the css folder file:

    {body
    background: url(/images/bg_body_winter.jpg) top of Center no-repeat scroll #C1CAD6;
    }
    {body
    Police: 100% Verdana, Arial, Helvetica, without serif.
    margin: 0;
    }

    I downloaded the site in a test folder on my server at fatcow.com. You can see the page using the link below.

    http://www.openrangeimaging.com/test/gravity-test/index-Test01.html

    The image appears as it should be in Dreamweaver Live View. It does not appear in Design view. It does not appear in the preview of the local file in a browser. The image does not appear when you look at the index file - test01.html that is located on the server by using the link above. The specified background color appears but not the image.

    I'm confused about how I should name the path to the image. I think it must be relative root of the site so that anywhere, I have download the website, the image can be found. Can someone tell me how I should name the path to the image properly.

    I feel that I should know how doing this and looked around for help online and tutorial books I have, but I just don't get it.

    TIA for any help.

    In your linked css file the path to the background image must be as shown below (note points both in front of the bar oblique leader)

    {body
    Background: url (.. / images/bg_body_winter.jpg) no-repeat scroll top centre #C1CAD6;
    }

    If you have this image, the browser is trying to find a 'pictures' folder in your "css" folder and it appears no one.

    If you include the colon before the first slash the browser search the folder 'images' outside your "css" folder and in the folder root site.

  • capacity of the type lost with the background image

    I found the code to load a bitmap as a background (JDE 4.2 so I'm on verticalfieldmanager of riding) but I've lost the ability to use the styles - specifically HCENTER for a horizontal field Manager.

    I thought that the code inline on Mount verticalfieldmanager was only on the functions you specify riding, but somehow styles don't seem to do anything right now.

    My class extends screen.  In addition to setting the style to the LabelField, I tried using a horizontal field with a HCENTER style Manager and adding that to the sublayout but everything continues to show left justified.

    LabelField myField = new LabelField("      ",FIELD_HCENTER){ public void paint(Graphics g){ g.setColor(Color.WHITE); super.paint(g); } };
    
    --- main class code snip ---
      super(NO_VERTICAL_SCROLL);
    
       mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )
            {
                public void paint(Graphics graphics)
                {
                    graphics.clear();
                    graphics.drawBitmap(0, 0, deviceWidth, deviceHeight, _backgroundBitmap, 0, 0);
                    super.paint(graphics);
                }
            };
    
            //this manger is used for adding the components
            subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | Manager.FIELD_HCENTER)
            {
                protected void sublayout( int maxWidth, int maxHeight )
                {
                    int displayWidth = deviceWidth;
                    int displayHeight = deviceHeight;
    
                    super.sublayout( displayWidth, displayHeight );
                    setExtent( displayWidth, displayHeight );
                }
            };
    
       subManager.add(myField);
    
       mainManager.add(subManager);
    
       this.add(mainManager);
    }
    

    Thanks for the help,
    Craig

    He finds... styles work but the fields are not the full width so that they were in "centered" relatively close to the left of the screen.

    Thanks for the research.  Fix use of USE_ALL_WIDTH to the verticalfieldmanager (probably could have done this in several places).

    Kind regards
    Craig

  • Problems with transparent background images

    Hello!

    I have a transparent background (in PNG format) image and when I import it in first, is displayed with a black background. How to solve this problem? Could you help me, please?

    Transparency in the dark shows.

    Put an image under the image in the timeline to check if they have really no transparency.

  • Problems with a background image using as a model in gradient mesh

    So, basically, I am DETERMINED to learn how to use the gradient in 5.1 mesh.  I tried to do this well known exercise of red pepper (I will give the URL if someone did not.) Everything was fine until I actually tried to use the jpg background pepper itself in mode plotted as a template. The idea is to pick up the colors of the model of the pepper and then use them as color gradient mesh. No matter how I tried to make fool that just would not work. Here is a copy of a post that someone else is on this exact issue in 2012:

    If you are working on a gradient mesh and use image model as a guide, you want to work in the outline preview, so you can see the art underlying to determine wht you establish and also it allows then to use the Eyedropper to sample the color of the actual photo, so it can be translated to the mesh and you can simply switch to preview mode to check your progress.

    Very handy when you are working with gradient meshes if you use and which underlies the model to translate into art.

    (I can find the author and the URL for the quote if necessary)

    That sounds good, but sampling of the color of the photo and then actually use it on the mesh gradent points just don't seem to work for me. If they did the job for the tutorial of pepper, then there clearly must be a way! But I was not able to find it, and I spent an insane amount of time on it. any suggestions appreciated!

    RealAnise wrote:

    the mesh layer and the embedded layer are going in and out of mode plotted as a single unit. I tried each selected, locking and unlocking each, dating back to the modes associated, etc.. I can not even put just a layer mode plotted.

    Make sure you have two separate layers (not two sublayers within the same layer). To put just the layer of mesh in tracks mode, command (window: Ctrl)-click on the eyeball. See screenshot:

  • How to set text so that it looks like "in perspective" with a background image?

    (In Illustrator)

    Use the perspective grid.

    Illustrator help | On the Perspective grid

  • Grid height of container to 100% with background image

    Hello

    I am a beginner with grids of fluid... I want to get whaY I always used to call a div wrapper - up to 100% with a background image, so I can put all my tests on top of it... and I can't get the grid container to stretch 100%...

    I would like to use the container to contain the image, and then run the other diving on top (within) can it... someone please give me a leg upward?

    Thank you

    Try this:

    Resizable background image full Page

    Nancy O.

  • Border problems with background image

    Hello

    I have a problem with my background image. I have fillings of browser size the original value and activated scale option in the middle. The image has a resolution of 1920x1080px. But when I now change the size of my browser I get a white border on the left or on the right size.


    Small to large size of Office Office:

    https://DL.dropboxusercontent.com/u/84237067/kleinzugross.PNG

    Large size of small office desktop:

    https://DL.dropboxusercontent.com/u/84237067/grosszuklein.PNG

    Hope you understand me, my English for this specific part is not perfect it.

    Greetings

    Marcel

    I checked out the site but don't see any white space on the page with large screens, I think that you have already solved the problem?

    Thank you

    Sanjit

  • Hotspots or links on background image with checkerboard to fluid.

    I have a fluid grid presentation in CS6 with a home page with a background image (javascript that loads different images.  What is the best way to bind or 'hot spots' more than one large image for three menu items in random places on this page?

    Is your native Photoshop PSD image with layers?  You must save the background (building & logo) as a single image layer.  Then each of the 3 menu items save it as transparent PNGs without the background layer.

    Put the background.jpg in your head with CSS.

    Insert the Menu.pngs in your HTML and link them as needed.

    Just to let you know, the web pages that contain nothing but images do not exist for the search engines, readers screen or the language translators.  You really need to insert text rich true keyword inside

    ,

    ,

    and

    Tags.   Without content keyword rich, nobody will ever find your site in searches on the web.

    Also consider that many mobile users disable the images to record the minutes of data.  If your site is nothing more than images, they won't see much.

    Nancy O.

Maybe you are looking for