91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-25
  • 語言: Java
  • 標(biāo)簽: 安卓??

資源簡介

安卓開發(fā)可以拖拽,拖拽后自動(dòng)吸附到手機(jī)屏幕邊的自定義view(已更新之前的有問題)

資源截圖

代碼片段和文件信息

package?com.ggx.test;

import?android.animation.objectAnimator;
import?android.content.Context;
import?android.support.design.widget.FloatingActionButton;
import?android.util.AttributeSet;
import?android.util.Log;
import?android.view.MotionEvent;
import?android.view.ViewGroup;
import?android.view.animation.DecelerateInterpolator;


/**
?*?Created?by?jerry.guan?on?2/15/2017.
?*/

public?class?DragFloatActionButton?extends?FloatingActionButton{

????private?int?parentHeight;
????private?int?parentWidth;

????public?DragFloatActionButton(Context?context)?{
????????super(context);
????}

????public?DragFloatActionButton(Context?context?AttributeSet?attrs)?{
????????super(context?attrs);

????}

????public?DragFloatActionButton(Context?context?AttributeSet?attrs?int?defstyleAttr)?{
????????super(context?attrs?defstyleAttr);

????}


????private?int?lastX;
????private?int?lastY;

????private?boolean?isDrag;

????@Override
????public?boolean?onTouchEvent(MotionEvent?event)?{
????????int?rawX?=?(int)?event.getRawX();
????????int?rawY?=?(int)?event.getRawY();
????????switch?(event.getAction()?&?MotionEvent.ACTION_MASK)?{
????????????case?MotionEvent.ACTION_DOWN:
????????????????setPressed(true);
????????????????isDrag=false;
????????????????getParent().requestDisallowInterceptTouchEvent(true);
????????????????lastX=rawX;
????????????????lastY=rawY;
????????????????ViewGroup?parent;
????????????????if(getParent()!=null){
????????????????????parent=?(ViewGroup)?getParent();
????????????????????parentHeight=parent.getHeight();
????????????????????parentWidth=parent.getWidth();
????????????????}
????????????????break;
????????????case?MotionEvent.ACTION_MOVE:
????????????????if(parentHeight<=0||parentWidth==0){
????????????????????isDrag=false;
????????????????????break;
????????????????}else?{
????????????????????isDrag=true;
????????????????}
??????????????

評論

共有 條評論