O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello Rendering

Rendering with RenderScript is a little bit more complicated than simply invoking a script function, and requires a little more work before you can see anything on the screen. You will need to:

  • Create a script that does the rendering.
  • Create a RenderScriptGL context object.
  • Create a class that extends RSSurfaceView.
  • Set your RSSurfaceView as the content view for your activity.

Creating a Rendering Script

Our first rendering script will be extremely simple as it will only change the background color to some random color. The script is shown in Listing 9–5 and is in a file called hellorendering.rs. The names of the RenderScript files are important as they define the resource name (in that case R.raw.hellorendering, which is simply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required