Android如何放置多个逐帧imageView动画

Android如何放置多个逐帧imageView动画,android,android-layout,animation,Android,Android Layout,Animation,我有一个片段中的逐帧动画 但是我需要把动画放在不同的地方 到目前为止,我可以制作一个动画 [头上的那个] 那么,如何将其他动画放置在特定的X&Y位置上,并使它们具有动画效果呢 下面是我使用的代码: .xml 那么我如何避免制作动画0、动画1、动画n呢 同样,只是在不同的地方 另外请注意,我使用的是不推荐的AbsoluteLayout 谢谢 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="ht

我有一个片段中的逐帧动画

但是我需要把动画放在不同的地方

到目前为止,我可以制作一个动画 [头上的那个]

那么,如何将其他动画放置在特定的X&Y位置上,并使它们具有动画效果呢

下面是我使用的代码:

.xml

那么我如何避免制作动画0、动画1、动画n呢

同样,只是在不同的地方

另外请注意,我使用的是不推荐的
AbsoluteLayout

谢谢

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="#FF0000">


<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">

       <ImageView 
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:src="@drawable/home_bgnd" android:scaleType="fitXY" />




    <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

        <ImageView     android:id="@+id/imgTesto"
       android:contentDescription="@string/imageFrag1"
       android:layout_x="265dp"
       android:layout_y="23dp"
            android:layout_width="41dp" 
            android:layout_height="41dp"
            android:src="@drawable/c_0"
    />

   <ImageView     android:id="@+id/imgTesto1"
       android:contentDescription="@string/imageFrag1"
       android:layout_x="265dp"
       android:layout_y="100dp"
            android:layout_width="41dp" 
            android:layout_height="41dp"
            android:src="@drawable/c_0"
    />

    </AbsoluteLayout>


</RelativeLayout>


<Button
       android:id="@+id/button1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="TesteoB" />


</LinearLayout>
public class HomeTab extends Fragment {
    /* (non-Javadoc)
     * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
     */

    AnimationDrawable animation;

    AnimationDrawable animation1;

    //ImageButton yourButton = new ImageButton(this);


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        if (container == null) {
            // We have different layouts, and in one of them this
            // fragment's containing frame doesn't exist.  The fragment
            // may still be created from its saved state, but there is
            // no reason to try to create its view hierarchy because it
            // won't be displayed.  Note this is not needed -- we could
            // just run the code below, where we would create and return
            // the view hierarchy; it would just never be used.
            return null;
        }


        //animation 0
        animation = new AnimationDrawable();
        animation.addFrame(getResources().getDrawable(R.drawable.c_0), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c1), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c2), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c3), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c4), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c5), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c6), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c7), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c8), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c9), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c10), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c9), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c8), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c7), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c6), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c5), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c4), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c3), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c2), 100);
        animation.addFrame(getResources().getDrawable(R.drawable.c1), 100);

        animation.setOneShot(false);


        //animation 1
        animation1 = new AnimationDrawable();
        animation1.addFrame(getResources().getDrawable(R.drawable.c_0), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c1), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c2), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c3), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c4), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c5), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c6), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c7), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c8), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c9), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c10), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c9), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c8), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c7), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c6), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c5), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c4), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c3), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c2), 100);
        animation1.addFrame(getResources().getDrawable(R.drawable.c1), 100);

        animation1.setOneShot(false);



        View V = inflater.inflate(R.layout.tab_home_layout, container, false);


        ImageView imageView = (ImageView)V.findViewById(R.id.imgTesto); //mestrua imagen ok, en el fragmentus

        //animation 0
        imageView.setBackgroundDrawable(animation);

        imageView.post(new Starter());

        //animation 1
        /*
        ImageView imageView1 = (ImageView)V.findViewById(R.id.imgTesto1); //mestrua imagen ok, en el fragmentus

           imageView1.setBackgroundDrawable(animation);

            imageView1.post(new Starter());
        */
        return V;


    }


     class Starter implements Runnable {

        public void run() {
            animation.start();        
        }

    }





}