Android中轴旋转特效实现,几张图片自动切换

本文介绍了如何在Android应用中创建一个3D轴旋转的图片切换特效,通过自定义Animation类来实现这一动态视觉效果。
摘要由CSDN通过智能技术生成

几张图片以3D立体旋转的效果进行切换(此例由此处参考而来

public class MainActivity extends Activity
{
   
    private LinearLayout layout;  //根布局;
    private ImageView picture, picture1;  //用于展示图片详细的ImageView;
    int[] imgs = {R.drawable.bird, R.drawable.winter, R.drawable.great_wall, R.drawable.water_fall};  //创建一个数组,存放要切换的图片;

    Boolean flag = true;  
    int index = -1;                                       //要加载的图片脚标;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        layout = (LinearLayout) findViewById(R.id.layout);
        picture = (ImageView) findViewById(R.id.picture);   
        picture1 = (ImageView) findViewById(R.id.picture1);     

        picture.setVisibility(View.GONE);
        new Thread()
        {
            @Override
            public void run() 
            {
                while(flag)
                {
                    if(index < imgs.length-1)
                    {               
                        index++;
                        handler.sendEmptyMessage(0);
                    }           
                    else if(index >= imgs.length-1)
                    {
                        flag = false;
                    }
                    try 
                    {
                        Thread.sleep(3500);
                    } catch (InterruptedException e) 
                    {
                        e.printStackTrace();
                    }
                }

            }
        }.start();
    }
    Handler handler = new Handler()
    {
        @Override
        public void handleMessage(Message msg) 
        {
            super.handleMessage(msg);
            if(msg.what == 0)
   
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值