Background animated image

前端 未结 1 1555

I am wondering how I can do the following. I want my app background to be animated (let\'s say birds flying sort of what live wall papers look like). Is this usually done using

1条回答
  •  不知归路
    2021-02-10 09:26

    You can do it by using GIF image also, but first convert that GIF to frames

    in xml

    
    
    

    in java

    public class MainActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        ImageView i = (ImageView)findViewById(R.id.img1);
        i.setBackgroundResource(R.drawable.gif);
    
        AnimationDrawable pro = (AnimationDrawable)i.getBackground();
        pro.start();
    }   
    }
    

    in drawable create animation file

    
      
      
       
      
      
      
      
      
      
      
      
      
      
    
    
    

    Hope this might help you

    0 讨论(0)
提交回复
热议问题