2017-07-17 55 views
0

我正在使用「me.everything:overscroll-decor-android:1.0.4」。 我可以從圖像視圖獲取偏移值,我試圖向下滑動? 文檔說明
OverScrollDecoratorHelper.setUpStaticOverScroll(view,OverScrollDecoratorHelper.ORIENTATION_VERTICAL); 我的代碼是OverScrollDecoratorHelper從視圖獲取onOverScrollUpdate回調

@BindView(R.id.swipeDownImgV) 
ImageView swipeDownImgV; 


@Override 
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.no_orders_fragment, container, false); 
    ButterKnife.bind(this, view); 

    setUpSwipeListener(); 

    return view; 
} 

private void setUpSwipeListener() { 

    OverScrollDecoratorHelper.setUpStaticOverScroll(swipeDownImgV, OverScrollDecoratorHelper.ORIENTATION_VERTICAL) 
      .setOverScrollUpdateListener(new IOverScrollUpdateListener() { 
       @Override 
       public void onOverScrollUpdate(IOverScrollDecor decor, int state, float offset) { 
        Log.d(Tag.SWIPE, offset + " offset"); 
       } 
      }); 

但它沒有效果,我做錯了什麼?謝謝!

回答

0

解決!只需要把圖像,滾動型

<ScrollView 
    android:id="@+id/swipeDownContainerScrlV" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/v16dp" 
     android:rotation="-90" 
     android:src="@drawable/no_order_swipe_arrow" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 
</ScrollView> 

d/SWIPE:2.3315098偏移

d/SWIPE:5.9953127偏移

d/SWIPE:8.992973偏移

d/SWIPE:10.325269偏移

D/SWIPE:11.990633偏移量