• android之滑屏


    <LineLayout>

    <ViewFlipper android:id="@+id/ViewFlipper"
      android:layout_width="fill_parent" android:layout_height="fill_parent">
      <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical" android:layout_width="fill_parent"
       android:layout_height="fill_parent">
       <TextView android:text="第 1 页"
        android:textSize="35dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="115dp"
        android:layout_y="20dp"/>
      </AbsoluteLayout>
      <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical" android:layout_width="fill_parent"
       android:layout_height="fill_parent">
       <TextView android:text="第 2 页"
        android:textSize="35dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="120dp"
        android:layout_y="20dp"/>
      </AbsoluteLayout>
      <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical" android:layout_width="fill_parent"
       android:layout_height="fill_parent">
       <TextView android:text="第 3 页"
        android:textSize="35dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="120dp"
        android:layout_y="20dp"/>
      </AbsoluteLayout>
     </ViewFlipper>

    </LineLayout>

    public class MainActivity extends Activity implements OnGestureListener {
     private ViewFlipper flipper;
     private GestureDetector detector;

     @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      

     
        
      detector = new GestureDetector(this);
      flipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper);
     }
      
     public boolean onDoubleTap(MotionEvent e) {  
            if(flipper.isFlipping()) {  
                flipper.stopFlipping();  
            }else {  
                flipper.startFlipping();  
            }  
            return true;  
         } 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
      return this.detector.onTouchEvent(event);
     }

     
     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {   
      
       
      if (e1.getX() - e2.getX() > 60) {
      
       this.flipper.showNext();
       return true;
      } else if (e1.getX() - e2.getX() < -60) {
      
       this.flipper.showPrevious();
       return true;
      }
      return false;
     }

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

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

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

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

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


     

  • 相关阅读:
    P1535 游荡的奶牛
    rmq
    bsgs算法详解
    P1396 营救
    P1547 Out of Hay
    P1474 货币系统 Money Systems
    P1209 [USACO1.3]修理牛棚 Barn Repair
    P1208 [USACO1.3]混合牛奶 Mixing Milk
    P1108 低价购买
    android屏幕适配的全攻略--支持不同的屏幕尺寸适配平板和手机
  • 原文地址:https://www.cnblogs.com/wangheblog/p/3036634.html
Copyright © 2020-2023  润新知