Haciendo burbujas flotantes

I'm trying to make the background of my app have randomly floating bubbles. I've been looking around for anything similar, such as falling snowflakes, rain, etc. but I can't seem to find any examples.

Even if I can't make a bubble.png float randomly upwards, I'd like to at least have a . character or something that could represent "bubbles" like in a soda.

Any ideas or references? Thanks!

preguntado el 27 de agosto de 11 a las 18:08

1 Respuestas

You could place a SurfaceView behind your primary UI in a FrameLayout and draw the bubbles in the SurfaceView following one of the available tutorials. The rest of your UI would then overlay on top.

Ejemplo:

<FrameLayout android:layout_width="match_parent"
             android:layout_height="match_parent">
    <SurfaceView android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:id="@+id/surface" />
    <FrameLayout android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:id="@+id/app_content">
        <!-- Normal app UI goes here -->
    </FrameLayout>
</FrameLayout>

advertencia: No matter what approach you take you're going to be redrawing the entire screen quite frequently several times per frame. (Animating the background plus drawing the UI.) Some ways will be faster than others but you are choosing to do more work than most apps do in drawing their UI. You will need to be mindful of performance and small inefficiencies; they will add up quickly.

Respondido 27 ago 11, 23:08

Awesome thanks. I'm actually more interested in the code than the layout. Do you know of any good tutorials on randomizing and moving instances of small photos? - ajwest

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.