zoukankan      html  css  js  c++  java
  • ViewFlipper 在同一背景下 页面左右滑动

     <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>
    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;
        }

     in_left.xml

    <?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>

    in_right.xml

    <?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>
    <?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>
    <?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>
  • 相关阅读:
    初始化注解和销毁注解
    MySQL、SQLServer、Oracle 分组排序
    mybatis 中SQLServer 和 mysql 模糊查询 不同点
    SpringBoot学习之logback.xml 配置指定包或类输出至单独的日志文件中
    类比 RocketMq 和 淘宝消息服务:
    SVN提交文件失败:系统找不到指定路径
    官网下载MySQL 并安装
    Java 变量参数传入方法,方法结束后传入的值
    03-类与对象课后作业(1)
    02方法-课后动手动脑
  • 原文地址:https://www.cnblogs.com/linximeng/p/3755178.html
Copyright © 2011-2022 走看看