Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:56:48+00:00 2026-06-09T10:56:48+00:00

I am new to BlackBerry Development (5.0). I have a little experience in Android

  • 0

I am new to BlackBerry Development (5.0). I have a little experience in Android Applications Development.
What I’m trying to do is fill an image on the whole screen (Horizontally)
Similar to what you could do in Android using fill_parent in a layout file.
I’ve looked on some forums to find a solution, but didn’t get a satisfactory one.

This is how I’m getting my image

Bitmap headerLogo = Bitmap.getBitmapResource("uperlogo.png");
BitmapField headerLogoField = 
    new BitmapField(headerLogo, BitmapField.USE_ALL_WIDTH | Field.FIELD_HCENTER);
setTitle(headerLogoField);

This code is giving me my header on top (as required) and in the center. I simply want this to stretch horizontally to cover all space.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:56:49+00:00Added an answer on June 9, 2026 at 10:56 am

    It is possible to stretch the Bitmap horizontally before creating the BitmapField, and that will solve the problem. But stretching Bitmap and using it as title will create problem for devices that supports screen rotation (e.g. Storm, Torch series). In that case you have to maintain two stretched Bitmap instance, one for the portrait mode and other for landscape mode. And you also need to write some extra code for setting the appropriate Bitmap depending on the orientation. If you don’t want to do that then check following 2 approaches:

    Using CustomBitmapField instance

    A CustomBitmapField that can stretch Bitmap horizontally can be used. Check the implementation.

    class MyScreen extends MainScreen {
    
        public MyScreen() {
            Bitmap bm = Bitmap.getBitmapResource("uperlogo.png");
            setTitle(new CustomBitmapField(bm));
        }
    
        class CustomBitmapField extends Field {
            private Bitmap bmOriginal;
            private Bitmap bm;
    
            private int bmHeight;
    
            public CustomBitmapField(Bitmap bm) {
                this.bmOriginal = bm;
                this.bmHeight = bm.getHeight();
            }
    
            protected void layout(int width, int height) {
                bm = new Bitmap(width, bmHeight);
                bmOriginal.scaleInto(bm, Bitmap.FILTER_BILINEAR);
                setExtent(width, bmHeight);
            }
    
            protected void paint(Graphics graphics) {
                graphics.drawBitmap(0, 0, bm.getWidth(), bmHeight, bm, 0, 0);
            }
        }
    }
    

    Using Background instance

    Background object can solve the problem easily. If a Background instance can be set to a HorizontalFieldManager which will use all the width available to its, then in case of screen rotation it will take care of its size and background painting. And the Background instance will itself take care of the streching of the supplied Bitmap. Check the following code.

    class MyScreen extends MainScreen {
    
        public MyScreen() {
            setTitle(getMyTitle());         
        }
    
        private Field getMyTitle() {
            // Logo.
            Bitmap bm = Bitmap.getBitmapResource("uperlogo.png");
    
            // Create a manager that contains only a dummy field that doesn't 
            // paint anything and has same height as the logo. Background of the 
            // manager will serve as the title.
    
            HorizontalFieldManager hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
            Background bg = BackgroundFactory.createBitmapBackground(bm, Background.POSITION_X_LEFT, Background.POSITION_Y_TOP, Background.REPEAT_SCALE_TO_FIT);
            hfm.setBackground(bg);
            hfm.add(new DummyField(bm.getHeight()));
    
            return hfm;
        }
    
        // Implementation of a dummy field
        class DummyField extends Field {
            private int logoHeight;
    
            public DummyField(int height) {
                logoHeight = height;
            }
    
            protected void layout(int width, int height) {
                setExtent(1, logoHeight);
            }
    
            protected void paint(Graphics graphics) {
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Blackberry development and have come across something I don't understand. I
I am new to Blackberry development and Im trying to simple get a BrowserField
I'm new to Blackberry Development and i have to implement a search functionality. It
i am new in blackberry development. and i have task to develop the application
i am new in blackberry development world. and i have task to develop the
I'm new to Blackberry development. Currently, i have an instance of TableLayoutManager to add
I'm a BlackBerry native applications developer. I'm new in BB10 apps development. I'm supposed
I am new to webworks and whole BlackBerry Development and I got a question
I'm new to blackberry development. There is this question I've come across several times,
I'm new to Blackberry application development and I need a piece of advise. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.