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

Hi,
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"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    android:background="@drawable/splash0">
  12.  
  13.         <LinearLayout
  14.  
  15.         android:layout_width="wrap_content"
  16.  
  17.         android:layout_height="wrap_content"
  18.  
  19.         android:background="@drawable/splash1"
  20.  
  21.         android:id="@+id/splash_1">
  22.  
  23.                 <LinearLayout
  24.  
  25.                 android:layout_width="wrap_content"
  26.  
  27.                 android:layout_height="wrap_content"
  28.  
  29.                 android:id="@+id/splash_2"
  30.  
  31.                 android:background="@drawable/splash2">
  32.  
  33.                 </LinearLayout>
  34.  
  35.         </LinearLayout>
  36.  
  37. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


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,
navajo
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Top

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 (http://developer.android.com/reference/ ... 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
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
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.
BUKsAPPs
Claustrum Lite - Area capture game
R:P:S Academy - play Rock/Paper/Scissors online
BUKsAPPs
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?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Top

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

Who is online

Users browsing this forum: No registered users and 6 guests