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 9057661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:31:03+00:00 2026-06-16T14:31:03+00:00

Here is the problem. For performance reasons, I choose to use a SurfaceView to

  • 0

Here is the problem.
For performance reasons, I choose to use a SurfaceView to draw a table-like form, and because this stuff is full of data I use a ScrollView as SurfaceView parent.

Happy to see it works fine on my personal development-dedicated phone (HTC Desire HD 2.3.7), I tried to test it on one of my company development-dedicated phone (Google Nexus S 4.1.?) and then on my personal phone (HTC One X 4.1.1).

Something went wrong on those two last ones, my SurfaceView just turned black after some ~80px scroll and turned back to what it should look like when I scrolled back under this ~80px (depends on screen size).

Trying to avoid this blackout, I tested under some emulators…

From 2.2 (customer’s wish) to 4.0.4, it works just great.

The joke is, under 4.2… it works too!

Definitely, that is only under 4.1.x that the SurfaceView turns black!

Here is my SurfaceView code, that I just copied from the sample you can find here.

public class MySurfaceView extends SurfaceView
{
    public MySurfaceView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        // I use another SurfaceView behind to draw a grid
        // that is scroll independent with a white background
        this.setZOrderOnTop(true);
        // Same reason here
        this.getHolder().setFormat(PixelFormat.TRANSPARENT);
        this.getHolder().addCallback(this);
        this.getHolder().setSizeFromLayout();
        // Tried without this line and with "software" and "none" types too
        // and hardware acceleration on application and activity
        this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }

    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        canvas.drawSomething()...
    }

    public void surfaceCreated(SurfaceHolder holder)
    {
        this.setWillNotDraw(false);

        this.thread = new MySurfaceViewThread(this.getHolder(), this);
        this.thread.setRunning(true);
        this.thread.run();
    }

    public void surfaceDestroyed(SurfaceHolder holder)
    {
        this.thread.setRunning(false);
        boolean retry = true;
        while(retry)
        {
            try
            {
                this.thread.join();
                retry = false;
            }
            catch(Exception exception)
            {
                Log.v(TAG, exception.getClass().getName(), exception);
            }
        }
    }
}
  • 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-16T14:31:04+00:00Added an answer on June 16, 2026 at 2:31 pm

    This code snippet could be an answer

    if(VERSION.SDK_INT != VERSION_CODES.JELLY_BEAN)
    {
        this.setZOrderOnTop(true);
    }
    

    But the problem with doing this is that the background gets black.

    I have to draw the grid I drawn in the “background” SurfaceView on this one too for this specific android version.

    That is not a good solution, because drawing that grid in this SurfaceView breaks the smoothness of the scroll and the pinch-to-zoom.

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

Sidebar

Related Questions

This question involves memory management in Java for performance reasons: because I am developing
We are experiencing performance problems using a table variable in a Stored Procedure. Here
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
This is another stab into a problem I posted here . Please don't close
The problem here is how to add an NSPopUpButton in Xcode 4's Interface Builder
date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except
I have a problem here im trying to upload a file first time it
Im having a problem here. i downloaded jake wharton. He gave an example of
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However

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.