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

  • Home
  • SEARCH
  • 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 8312273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:06:34+00:00 2026-06-08T20:06:34+00:00

I am making a custom list view item. Extending View and overriding the onDraw

  • 0

I am making a custom list view item. Extending View and overriding the onDraw method.

private Bitmap bmpScaledBackground; //with size:(screenWidth , screenHeight/4)
@Override
public void onDraw(Canvas canvas){
    canvas.drawBitmap(bmpScaledBackground , 0 , 0 , null);
    //...more of that
}

So far it works quite well on normal phones such as Galaxy SII.

However when it comes to Galaxy Nexus, the performance is poor. I believe it is because of the large resolution of GN (1280×720).

In the above case, the background bitmap (bmpScaledBackground) alone is as large as 720×320 which takes a long time to draw. Not to mention the risk of OOM.

I am writing to ask if there is a more scalable way (except SurfaceView and OpenGL) to make a custom view.

Sorry for my poor english.

  • 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-08T20:06:36+00:00Added an answer on June 8, 2026 at 8:06 pm

    My options:
    1,Use ‘xxx.9.png’ format pics resources.
    2,Use a compress bitmap.

        //get opts
        BitmapFactory.Options opts =  new BitmapFactory.Options();
        opts.inJustDecodeBounds =  true ;
        Bitmap bitmap = BitmapFactory.decodeFile(imageFile, opts);
    
        //get a appropriate inSampleSize
        public static int computeSampleSize(BitmapFactory.Options options,
             int minSideLength,  int maxNumOfPixels) {
         int initialSize = computeInitialSampleSize(options, minSideLength,
                 maxNumOfPixels);
         int roundedSize;
         if (initialSize <=  8 ) {
             roundedSize =  1 ;
             while (roundedSize < initialSize) {
                 roundedSize <<=  1 ;
             }
         }  else {
             roundedSize = (initialSize +  7 ) /  8 *  8 ;
         }
         return roundedSize;
    }
    
    private static int computeInitialSampleSize(BitmapFactory.Options options,
             int minSideLength,  int maxNumOfPixels) {
         double w = options.outWidth;
         double h = options.outHeight;
         int lowerBound = (maxNumOfPixels == - 1 ) ?  1 :
                 ( int ) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
         int upperBound = (minSideLength == - 1 ) ?  128 :
                 ( int ) Math.min(Math.floor(w / minSideLength),
                 Math.floor(h / minSideLength));
         if (upperBound < lowerBound) {
             // return the larger one when there is no overlapping zone.
             return lowerBound;
         }
         if ((maxNumOfPixels == - 1 ) &&
                 (minSideLength == - 1 )) {
             return 1 ;
         }  else if (minSideLength == - 1 ) {
             return lowerBound;
         }  else {
             return upperBound;
         }
    }  
    //last get a well bitmap.
    BitmapFactory.Options opts =new BitmapFactory.Options(); 
    opts.inSampleSize = inSampleSize;// inSampleSize should be index value of 2.
    Bitmap wellbmp =null; 
    wellbmp = BitmapFactory.decodeResource(getResources(), mImageIds[position],opts);
    

    Good luck!
    ^-^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making use of a custom cursor on itemRenderers in a List component.
I'm making a custom adapter so that I can display a list of items
Is there a way to create a search filter over my custom list view
I'm making a custom list of nodes and their comments. I'd like to be
Using Microsoft Visual C# I am making a Custom Control that has a list
I am making a custom ol>li to look like this 1 | List content
Briefly: I'm making a custom view, I want a field listing the two taxonomy
I making a custom button, and I need to add a PreviewKeyDown event, whenever
I'm making a custom ImageView . One of the methods is to load an
I'm making a custom activity for a workflow, but am having trouble with InArguments.

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.