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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:34:11+00:00 2026-05-26T05:34:11+00:00

I have set a GradientDrawable as background. While doing some 3d transaction (especially at

  • 0

I have set a GradientDrawable as background. While doing some 3d transaction (especially at the Y axis) the GradientDrawable redraws it self and the famerate is not good.

  • I cannot cache the view that the drawing is set as background because
    i want other views on top of that to animate.
  • I cannot put another view just for the background and cache that view
    cause then that view only beeing fullscreen will cause the same
    problems.
  • I cannot use windowsDecorator for the background.

So what i want is a way to stop the GradientDrawable to try to redraw itself during the animation. I think jumpToCurrentState() does what i want but i want it to work on API level >= 8 and jumpToCurrentState() is only for API level >=11. Also i wish i knew what jumpToCurrentState does exactly to port it to the API lvl 8 but can’t find the function anywhere in the drawable(source not released?)

So is there any way to cache the drawable it self and not the view containing that Drawable?.

The last resort will be to not draw the background during animations but i really really want to avoid that.

  • 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-05-26T05:34:11+00:00Added an answer on May 26, 2026 at 5:34 am

    I ended up creating a bitmap caching system for the GradientDrawable it self. (Didn’t want to cache the view that has this drawable as a background).

    This gives a great speed boost for animations.

      public class PGradientDrawable extends GradientDrawable {
    
        private int firstColor;
        private int secondColor;
        private Paint cachePaint = new Paint();
        private Canvas cacheCanvas = new Canvas();
        private Bitmap bitmap;
    
        public PGradientDrawable(Orientation angle, int[] intarray) {
            super(angle, intarray);
            firstColor = intarray[0];
            secondColor = intarray[1];
        }
    
        public boolean isBackground = false;
        boolean firstTime = true;
    
        public void buildCache(int width, int height) {
            if (bitmap != null)
                bitmap.recycle();
            try {
                bitmap = Bitmap
                        .createBitmap(width, height, Bitmap.Config.ARGB_8888);
                bitmap.setDensity(context.getResources().getDisplayMetrics().densityDpi);
                cacheCanvas.setBitmap(bitmap);
                // TODO shader must be what the GradientDrawable is,type
                // orientation..
                cachePaint.setShader(new LinearGradient(0, 0, width, height,
                        firstColor, secondColor, Shader.TileMode.CLAMP));
                cacheCanvas.drawPaint(cachePaint);
    
            } catch (OutOfMemoryError e) {
                // clear the bitmap force draw() to repaint
                bitmap = null;
            }
    
        }
    
        @Override
        public void draw(Canvas canvas) {
            if (bitmap != null) {
                // Draw the bitmap
                canvas.drawBitmap(bitmap, 0, 0, null);
                return;
            }
            super.draw(canvas);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set a canvas' background to an image of a company logo. I
I have set of scripts for doing scripted installs. You can use the scripts
I have set up some database connection parameters on an OpenDS ldap server, using
I have set up an HttpHandler for *css to do some simple parsing: <handlers>
I have set up some custom symfony project-level settings in the file config/project.yml following
We have set up a system where notifications get sent to a user with
I have set up transactional replication between two SQL Servers on different ends of
I have set up a version control system using TortoiseSVN at my home to
I have set up a Django application that uses images. I think I have
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when

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.