Pro Android Graphics

Book description

Pro Android Graphics is a comprehensive goldmine of knowledge and techniques that will help you design, create, and optimize 2D graphics for use in your Android Jelly Bean applications. Android application developer and expert multimedia producer Wallace Jackson of Mind Taffy Design shows you how to leverage Android's powerful graphics APIs in conjunction with professional open source graphics design tools such as GIMP 2.8.6 and more.

You'll learn about:

  • The foundational graphics concepts behind the three core new media areas (digital imaging, digital video, and 2D animation) which relate to graphics design, and how to optimize these new media assets for your Android applications across iTVs, tablets, eReaders, game consoles, and smartphones.

  • Digital imaging techniques for Android apps design, including graphics design layouts and graphical user interface elements, and how to use image compositing techniques to take your digital imaging to far higher levels.

  • Advanced image compositing and blending techniques, using Android's PorterDuff, NinePatch, and LayerDrawable classes.

  • Advanced 2D animation techniques, using Android's Animation and AnimationDrawable classes.

  • Digital video optimization, playback, and streaming, using open source 3D (Terragen 3) and video (VirtualDub) applications, as well as professional video editing applications such as Squeeze Pro 9. You'll use these software packages with Android's VideoView and MediaPlayer classes, and add compositing to enhance your end-users' digital video experience.

  • What you'll learn

  • How to build graphics rich Android apps and games

  • What are the key Android Graphics support APIs: Images, Animation and Video Concepts

  • What are the digital imaging techniques for Android apps

  • What are the advanced animation techniques for Android apps

  • How to do digital video optimization for Android apps

  • Who this book is for

    Pro Android Graphics is written for experienced Android developers and advanced multimedia artisans, especially those who want to create rich, vibrant-looking graphics-related applications.

    Table of contents

    1. Title Page
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Author
    6. About the Technical Reviewer
    7. Acknowledgments
    8. Chapter 1: Android Digital Imaging: Formats, Concepts, and Optimization
      1. Android’s Digital Image Formats: Lossless Versus Lossy
      2. Android View and ViewGroup Classes: Image Containers
      3. The Foundation of Digital Images: Pixels and Aspect Ratio
      4. The Color of Digital Images: Color Theory and Color Depth
      5. Representing Colors in Android: Hexadecimal Notation
      6. Image Compositing: Alpha Channels and Blending Modes
      7. Digital Image Masking: A Popular Use for Alpha Channels
      8. Smoothing Edges in a Mask: The Concept of Anti-Aliasing
      9. Optimizing Digital Images: Compression and Dithering
      10. Download the Android Environment: Java and ADT Bundle
      11. Installing and Updating the Android Developer ADT Bundle
      12. Summary
    9. Chapter 2: Android Digital Video: Formats, Concepts, and Optimization
      1. Android Digital Video Formats: MPEG4 H.264 and WebM VP8
      2. Android VideoView and MediaPlayer Class: Video Players
      3. The Foundation of Digital Video: Motion, Frames and FPS
      4. Digital Video Conventions: Bit Rates, Streams, SD, and HD
      5. Digital Video Files for Android: Resolution Density Targets
      6. Optimizing Digital Video: Codecs and Compression
      7. Creating Your Pro Android Graphics App in Eclipse ADT
      8. Creating Your Video Start-Up Screen User Interface Design
      9. Taking a Look at Your Activity subclass
      10. Creating Your Video Assets: Using Terragen 3 3D Software
      11. Creating Uncompressed Video: Using VirtualDub Software
      12. Compressing Your Video Assets: Using Sorenson Squeeze
      13. Installing a Video Asset in Android: Using the Raw Folder
      14. Referencing the Video Asset in Your Android Application
      15. Summary
    10. Chapter 3: Android Frame Animation: XML, Concepts, and Optimization
      1. Frame Animation Concepts: Cels, Framerate, and Resolution
      2. Optimizing Frame Animation: Color Depth and Frame Rate
      3. Creating Frame Animation in Android Using XML Markup
      4. Android <animation-list> Tag: The Parent Frame Container
      5. Android’s <item> Tag: Specifying Your Animation Frames
      6. Creating a Frame Animation for our GraphicsDesign App
      7. Copying Resolution Density Target Frames
      8. Creating Frame Animation Definitions Using XML
      9. Reference the Frame Animation Definition in an ImageView
      10. Instantiating the Frame Animation Definition Using Java
      11. Summary
    11. Chapter 4: Android Procedural Animation: XML, Concepts, and Optimization
      1. Procedural Animation Concepts: Tweens and Interpolators
      2. Procedural Animation Data Values: Ranges and Pivot Point
      3. Procedural Animation Transforms: Rotate, Scale, Translate
      4. Procedural Animation Compositing: Alpha Blending
      5. Procedural Animation Timing: Using Duration and Offsets
      6. Procedural Animation Loops: RepeatCount and RepeatMode
      7. The <set> Tag: Using XML to Group Procedural Animation
      8. Procedural Animation vs. Frame Animation: The Trade-Off
      9. Creating Procedural Animation in your GraphicsDesign App
      10. Creating a Procedural Animation Definition Using XML
      11. Instantiating the Animation Object in
      12. Using Set to Create a More Complex Procedural Animation
      13. Rotation Transformation: Going a Bit Too Far with FX
      14. Tweaking Transform Values: The Ease of Adjusting XML
      15. Summary
    12. Chapter 5: Android DIP: Device-Independent Pixel Graphics Design
      1. How Android Supports Device Displays: UI Design and UX
      2. Device Display Concepts: Size, Density, Orientation, DIP
      3. Density Independence: Creating Similar User Experiencesl
      4. Android Multi-Screen Support Via <supports-screens> Tag
      5. Providing Device-Optimized User Interface Layout Designs
      6. Providing Device-Optimized Image Drawable Assets
      7. The DisplayMetrics Class: Size, Density, and Font Scaling
      8. Optimizing Android Application Icons for LDPI to XXXHDPI
      9. Installing the New App Icon in the Correct Density Folders
      10. Configuring the AndroidManifest.xml for Custom App Icon
      11. Testing the New Application Icon and Label on Nexus One
      12. Summary
    13. Chapter 6: Android UI Layouts: Graphics Design Using the ViewGroup Class
      1. Android ViewGroup Superclass: A Foundation for Layouts
      2. The ViewGroup LayoutParams Class: Layout Parameters
      3. Deprecated Layouts: AbsoluteLayout and SlidingDrawer
      4. Android’s Experimental Layout: SlidingPaneLayout
      5. Android RelativeLayout Class: Designing Relative Layouts
      6. Android LinearLayout Class: Designing Linear Layouts
      7. Android FrameLayout Class: Designing Frame Layouts
      8. Android GridLayout Class: Designing UI Layout Grids
      9. The DrawerLayout Class: Designing UI Drawer Layouts
      10. Adding Menu Items to Access the UI Layout Container
      11. Creating a Table of Contents Activity for Your UI Design
      12. Creating an XML Table of Contents LinearLayout UI Design
      13. Adding Text UI Widgets to the TOC UI Layout Container
      14. Using onOptionsItemSelected(  ) to Add Menu Functionality
      15. Testing the Table of Contents Activity on the Nexus One
      16. Summary
    14. Chapter 7: Android UI Widgets: Graphics Design Using the View Class
      1. The Android View Class: The Foundation for UI Widgets
      2. View Basic Properties: ID, Layout Positioning, and Size
      3. View Positioning Characteristics: Margins and Padding
      4. View Graphic Properties: Background, Alpha, and Visibility
      5. A View’s Functional Characteristics: Listeners and Focus
      6. Bookmark Utility UI: Using a RelativeLayout and TextView
      7. Using an ImageView Widget: The Cornerstone of Graphics
      8. Testing Your UI Design in the Nexus One Landscape Mode
      9. Adding a Drop Shadow Effect to an ImageView Image Asset
      10. Changing Your ImageView XML to Incorporate a New Asset
      11. Compositing a Background Image in Your RelativeLayout
      12. Summary
    15. Chapter 8: Advanced ImageView: More Graphics Design Using ImageView
      1. Graphics in Android: The Origins of the ImageView Class
      2. The ImageView.ScaleType Nested Class: Scaling Control
      3. Using AdjustViewBounds and How it Relates to ScaleType
      4. MaxWidth and MaxHeight: Controlling AdjustViewBounds
      5. Setting a Baseline in ImageView and Controlling Alignment
      6. Using the CropToPadding Method to Crop Your ImageView
      7. Tinting an ImageView and Color Blending Using PorterDuff
      8. Apply Tint to SkyCloud Image to Improve Shadow Contrast
      9. Cropping Your SkyCloud Image Asset Using CropByPadding
      10. Changing the Baseline Alignment Index for Your ImageView
      11. Performing Image Scaling: Margins and Padding Attributes
      12. Summary
    16. Chapter 9: Advanced ImageButton: Creating a Custom Multi-State ImageButton
      1. Button Graphics in Android: ImageButton Class Overview
      2. ImageButton States: Normal, Pressed, Focused, and Hovered
      3. ImageButton Drawable Assets: Compositing Button States
      4. An ImageButton Drawable: Setting Up the Multi-State XML
      5. Create All ImageButton State Assets: Density Resolutions
      6. Scaling the ImageButton Down to a UI Element-Like Scale
      7. Summary
    17. Chapter 10: Using 9-Patch Imaging Techniques to Create Scalable Imaging Elements
      1. Android NinePatchDrawable: A Foundation for NinePatch
      2. NinePatch Graphics Assets: A 9-Patch Concepts Overview
      3. The Android NinePatch Class: Creating a NinePatch Asset
      4. The Draw 9-Patch Tool: Create NinePatchDrawable Assets
      5. Implementing Your NinePatch Asset Using XML Markup
      6. Summary
    18. Chapter 11: Advanced Image Blending: Using Android PorterDuff Classes
      1. Pixel Blending: Take Image Compositing to the Next Level
      2. Android’s PorterDuff Class: The Foundation for Blending
      3. The PorterDuff.Mode Class: Android Blending Constants
      4. The PorterDuffColorFilter Class: Blending Your ColorFilter
      5. Applying ColorFilter Effects to Image Assets Using PorterDuff
      6. The PorterDuffXfermode Class: Apply Blending Constants
      7. The Paint Class: Apply a Blending Constant Onto an Image
      8. Using Bitmap Classes to Apply PorterDuff Between Images
      9. Using .setXfermode(  ) Method to Apply PorterDuffXfermode
      10. The Canvas Class: Creating a Canvas for Our Compositing
      11. Creating an ImageView in XML and Java to Display Canvas
      12. Writing the Canvas to an ImageView Via .setBitmapImage(  )
      13. Summary
    19. Chapter 12: Advanced Image Compositing: Using the LayerDrawable Class
      1. Layer Drawables: Take Image Compositing to a New Level
      2. Android’s LayerDrawable Class: A Foundation for Layers
      3. The <layer-list> Parent Tag: Setting Up Layers Using XML
      4. Instantiating a LayerDrawable for PorterDuff Compositing
      5. Create a Drawable Object to Hold the LayerDrawable Asset
      6. Cast a Drawable to a BitmapDrawable and Extract a Bitmap
      7. Modifying the PorterDuff Pipeline to Use a LayerDrawable
      8. Switch LayerDrawable Image Asset: Source to Destination
      9. Changing the LayerDrawable Layer Used in Our Pipeline
      10. Exercise for the Reader: Using Two LayerDrawable Assets
      11. Some Final Digital Image Compositing Caveats in Android
      12. Summary
    20. Chapter 13: Digital Image Transitions: Using the TransitionDrawable Class
      1. Transitions: Image Blending to Create an Illusion of Motion
      2. Android’s TransitionDrawable Class: A Transition Engine
      3. The <transition> Parent Tag: Setting Up Transitions in XML
      4. Instantiating ImageButton and TransitionDrawable Objects
      5. Using the .reverseTransition(  ) Method for Pong Transitions
      6. Advanced TransitionDrawable Compositing via ImageView
      7. Summary
    21. Chapter 14: Frame-Based Animation: Using the AnimationDrawable Class
      1. The AnimationDrawable Class: A Frame Animation Engine
      2. The DrawableContainer Class: A Multi-Drawable Drawable
      3. Creating Your AnimationDrawable Splashscreen Using Java
      4. Using the Android Runnable Class to Run Your Animation
      5. Creating a setUpAnimation(  ) Method for Your Animation
      6. Creating a New AnimationDrawable Object and Referencing Its Frames
      7. Using the AnimationDrawable Class’s .addFrame(  ) Method
      8. Configuring an AnimationDrawable by Using .setOneShot(  )
      9. Scheduling an AnimationDrawable Using the Handler Class
      10. Designing an AnimationDrawable to Loop Back to Frame 1
      11. Adding Event Handling to Allow Frame Animation by Click
      12. Summary
    22. Chapter 15: Procedural Animation: Using the Animation Classes
      1. The Animation Class: Your Procedural Animation Engine
      2. TranslateAnimation Class: Animation Subclass for Moving
      3. The ScaleAnimation Class: Animation Subclass for Scaling
      4. Scaling Up Your Logo: Using the ScaleAnimation Class
      5. AlphaAnimation Class: Animation Subclass for Blending
      6. Fading In Your PAG Logo: Using the AlphaAnimation Class
      7. The AnimationSet Class: Creating Complex Animation Sets
      8. Creating an AnimationSet for Your PAG Logo Animation
      9. RotateAnimation Class: Animation Subclass for Rotation
      10. Rotating Your PAG Logo: Using the RotateAnimation Class
      11. Using an Android Runnable Class to Run the AnimationSet
      12. Creating a TranslateAnimation Object for Your AnimationSet
      13. Summary
    23. Chapter 16: Advanced Graphics: Mastering the Drawable Class
      1. Android Drawable Resources: Types of Drawable Objects
      2. Creating a ShapeDrawable Object: XML <shape> Parent Tag
      3. The Android Drawable Class: The Blueprint for Graphics
      4. Creating Your Custom Drawable: ImageRoundingDrawable
      5. Creating a Paint Object to Use to Paint the Drawable Canvas
      6. The Android Shader Superclass: Texture Maps for Painting
      7. The Shader.TileMode Nested Class: Shader Tiling Modes
      8. The BitmapShader Class: Texture Mapping Using Bitmaps
      9. Creating and Configuring a BitmapShader for the Drawable
      10. Android Rect and RectF Classes: Defining the Draw Area
      11. Defining Your RectF Object and Calling .drawRoundRect(  )
      12. Summary
    24. Chapter 17: Interactive Drawing: Using Paint and Canvas Classes Interactively
      1. The Android onDraw(  ) Method: Drawing onto Your Screen
      2. The Android Canvas Class: The Digital Artisan’s Canvas
      3. The Android Paint Class: The Digital Artisan’s Paintbrush
      4. Setting Up Your GraphicsDesign Project for Your SketchPad
      5. Creating a Custom View Class: Your SketchPadView Class
      6. The Android Context Class: Telling Your Activity Where It Is
      7. Configuring Your SketchPadView(  ) Constructor Method
      8. Creating a Coordinate Class to Track Touch X and Y Points
      9. The Java List Utility Class: Get Your Collections in Order
      10. Java’s ArrayList Utility Class: An Array of Collection List
      11. Creating an ArrayList Object to Hold Your Touch Point Data
      12. Implementing Your .onDraw(  ) Method: Painting Your Canvas
      13. Creating Your OnTouchListener(  ) Method: Event Handling
      14. Android’s MotionEvent Class: Movement Data in Android
      15. Processing Your Movement Data: Using .getX(  ) and .getY(  )
      16. Coding Your SketchPad Activity: Using the SketchPadView
      17. Testing the SketchPad Activity Class: Handwriting a PAG Logo
      18. Paint Using a Bitmap Source: Implementing Your InkShader
      19. Summary
    25. Chapter 18: Playing Captive Video Using the VideoView and MediaPlayer Classes
      1. A Life of a Video: The Stages of a Video Playback Lifecycle
      2. Where Video Lives: The Data URI and Android’s Uri Class
      3. Android’s MediaPlayer Class: Controlling Video Playback
      4. The Android VideoView Class: The Video Asset Container
      5. Using the MediaPlayer Class: Looping a Video Seamlessly
      6. Setting Up Scaling Video Assets to Fit any Screen Aspect Ratio
      7. Optimizing Your Range of Video Asset Resolution Targets
      8. Using 16:9 Low Resolution 640x360 Digital Video Assets
      9. Using NetBook Resolution 1024x600 Digital Video Asset
      10. Using Low HD Resolution 1280x720 Digital Video Assets
      11. Using a True HD 1920x1080 Digital Video Asset for iTVs
      12. Analyzing Target Resolution Compression Ratio Results
      13. Using the WebM VP8 Codec to Compress Pseudo HD Video
      14. Using the WebM VP8 Codec to Compress True HD Video
      15. Summary
    26. Chapter 19: Streaming Digital Video from an External Media Server
      1. Can I Stream Video? Setting a Manifest Internet Permission
      2. When Video Lives Far Away: The HTTP URL and Your URI
      3. The ProgressDialog Class: Show Your Download Progress
      4. Implementing a ProgressDialog in the GraphicsDesign App
      5. Testing the Progress Dialog: Dealing with Compiler Errors
      6. Streaming Digital Video Using the WebM VP8 Video Codec
      7. Making Your Video Playback App Aware of Its Orientation
      8. Android’s Display Class: Physical Display Characteristics
      9. The Android DisplayManager Class: Managing the Display
      10. Android’s WindowManager Interface: Managing a Window
      11. Setting Up a Display Object to Ascertain the Device Rotation
      12. Android’s Surface Class: Grab Your Display’s Raw Buffer
      13. Using a .getRotation(  ) Method Call to Drive a Switch Loop
      14. Testing Streaming Video in Portrait and Landscape Orientations
      15. Some Caveats About Using Digital Video in Android
      16. Android’s DisplayMetrics Class: A Display’s Specifications
      17. Summary
    27. Index

    Product information

    • Title: Pro Android Graphics
    • Author(s):
    • Release date: October 2013
    • Publisher(s): Apress
    • ISBN: 9781430257851