Animation Problem

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Animation Problem

Postby navajo » Tue Feb 02, 2010 12:48 pm

I have 3 png-images with transparent areas integrated in one LinearLayout this way:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  3. <LinearLayout xmlns:android=""
  5.    android:orientation="vertical"
  7.    android:layout_width="fill_parent"
  9.    android:layout_height="fill_parent"
  11.    android:background="@drawable/splash0">
  13.         <LinearLayout
  15.         android:layout_width="wrap_content"
  17.         android:layout_height="wrap_content"
  19.         android:background="@drawable/splash1"
  21.         android:id="@+id/splash_1">
  23.                 <LinearLayout
  25.                 android:layout_width="wrap_content"
  27.                 android:layout_height="wrap_content"
  29.                 android:id="@+id/splash_2"
  31.                 android:background="@drawable/splash2">
  33.                 </LinearLayout>
  35.         </LinearLayout>
  37. </LinearLayout>
Parsed in 0.001 seconds, using GeSHi

I want to animate "splash_1" without animating his child "splash_2"!
If I rotate my splash_1_Layout then splash_2 is doing the same because his parent is rotating.
Is it possible to turn animation for splash_2 off? And how can I do that?
Few code snippets would be most helpful to me than explanations.

Thanks in advance,
In a world without walls and fences... who needs Windows and Gates?
Junior Developer
Junior Developer
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany


Postby MichaelEGR » Tue Feb 02, 2010 2:28 pm

It's early in the morning here and such and I haven't done this / implemented it in code as it's just an idea, but take a look at LayeredDrawable ( ... wable.html) and see if you can animate each layer (IE a unique drawable itself) independently. This may also reduce the extraneous nested LinearLayouts in your current layout.

LayerDrawable has XML definitions as so briefly defined in the documentation: "It can be defined in an XML file with the <layer-list> element. Each Drawable in the layer is defined in a nested <item>."

Another route is the coding option which is to simply implement this functionality (rotating bitmaps) in a custom component using the Android 2D API.

I'll be releasing a comprehensive framework that makes option 2 easy cheesy Q1 this year..
Founder & Principal Architect; EGR Software LLC
User avatar
Senior Developer
Senior Developer
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Postby BUKsAPPs » Tue Feb 02, 2010 3:30 pm

This too is just off the top of my head, so take it with a grain of salt.

Are all of your images drawn on top of one another?
How about putting all 3 LinearLayouts inside a FrameView. Then don't nest the LinearLayouts, make them all first level children of the FrameView. They will all be aligned to the top-left corner of the screen and drawn on top of each other and can be animated independantly. And once you do this, you might not need to make them LinearLayouts but ImageViews(Not positive these are animatable though) might work and be more specific.
Claustrum Lite - Area capture game
R:P:S Academy - play Rock/Paper/Scissors online
Experienced Developer
Experienced Developer
Posts: 71
Joined: Sat Jan 16, 2010 9:01 pm
Location: USA

Postby navajo » Tue Feb 02, 2010 5:12 pm

Many thanks volks,
you helped me a lot!

@BUKsAPPs: your solution is very simple and worked straightaway. Thanks again!
In a world without walls and fences... who needs Windows and Gates?
Junior Developer
Junior Developer
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany


Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests