码迷,mamicode.com
首页 > 其他好文 > 详细

ViewFlipper 在同一背景下 页面左右滑动

时间:2014-05-28 09:23:09      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:android   style   c   class   blog   code   

bubuko.com,布布扣
 <ViewFlipper
        android:id="@+id/ViewFlipper1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:inAnimation="@anim/push_left_in"
        android:outAnimation="@anim/push_left_out" >

        <include layout="@layout/item_viewpage_first" />

        <include layout="@layout/item_viewpage_second" />
    </ViewFlipper>
bubuko.com,布布扣
bubuko.com,布布扣
viewFli = (ViewFlipper) this.findViewById(R.id.ViewFlipper1);
        viewFli.setOnTouchListener(this);
        detector = new GestureDetector(this);


@Override
    public boolean onDown(MotionEvent e) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        if (e1.getX() - e2.getX() > 0) {
            this.viewFli.setInAnimation(AnimationUtils.loadAnimation(this,
                    R.anim.push_left_in));
            this.viewFli.setOutAnimation(AnimationUtils.loadAnimation(this,
                    R.anim.push_left_out));
            this.viewFli.showPrevious();
        } else {
            this.viewFli.setInAnimation(AnimationUtils.loadAnimation(this,
                    R.anim.push_right_in));
            this.viewFli.setOutAnimation(AnimationUtils.loadAnimation(this,
                    R.anim.push_right_out));
            this.viewFli.showNext();
        }
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
            float distanceY) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        // TODO Auto-generated method stub
        this.detector.onTouchEvent(arg1);
        return true;
    }
bubuko.com,布布扣

 in_left.xml

bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="500"
        android:fromXDelta="-100%p"
        android:toXDelta="0" />

    <alpha
        android:duration="500"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />

</set>

bubuko.com,布布扣

in_right.xml

bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="500"
        android:fromXDelta="100%p"
        android:toXDelta="0" />
    
    <alpha
        android:duration="500"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>
bubuko.com,布布扣
bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="500"
        android:fromXDelta="0"
        android:toXDelta="100%p" />
    
    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>
bubuko.com,布布扣
bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="500"
        android:fromXDelta="0"
        android:toXDelta="-100%p" />

    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />

</set>
bubuko.com,布布扣

 

ViewFlipper 在同一背景下 页面左右滑动,布布扣,bubuko.com

ViewFlipper 在同一背景下 页面左右滑动

标签:android   style   c   class   blog   code   

原文地址:http://www.cnblogs.com/linximeng/p/3755178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!