当前位置: 首页>>代码示例>>Java>>正文


Java NestedScrollView.getScrollY方法代码示例

本文整理汇总了Java中android.support.v4.widget.NestedScrollView.getScrollY方法的典型用法代码示例。如果您正苦于以下问题:Java NestedScrollView.getScrollY方法的具体用法?Java NestedScrollView.getScrollY怎么用?Java NestedScrollView.getScrollY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.NestedScrollView的用法示例。


在下文中一共展示了NestedScrollView.getScrollY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncOffset

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
  boolean isSelected = target == scroll;
  if (scroll instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) scroll;
    if (nestedScrollView.getScrollY() < verticalOffset || (!isSelected && isScrollToTop(target))) {
      nestedScrollView.scrollTo(0, verticalOffset);
    }
    if (isSelected && (nestedScrollView.getScrollY() < verticalOffset || verticalOffset == 0)) {
      nestedScrollView.scrollTo(0, 0);
      smoothAppBarLayout.syncOffset(0);
    }
  } else if (scroll instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) scroll;
    boolean isAccuracy = recyclerView.getLayoutManager().findViewByPosition(ObservableRecyclerView.HEADER_VIEW_POSITION) != null;
    if (isAccuracy && recyclerView.computeVerticalScrollOffset() < verticalOffset) {
      recyclerView.scrollBy(0, verticalOffset - recyclerView.computeVerticalScrollOffset());
    } else if (!isSelected && isScrollToTop(target)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
    }
    if (isAccuracy && isSelected && (recyclerView.computeVerticalScrollOffset() < verticalOffset || verticalOffset == 0)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
      smoothAppBarLayout.syncOffset(0);
    }
  }
  return true;
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:27,代码来源:Utils.java

示例2: onScrollChanged

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
public void onScrollChanged(NestedScrollView who, int l, int t, int oldl, int oldt) {
    //Y轴偏移量
    float scrollY = who.getScrollY();
    //变化率
    float headerBarOffsetY = headerHeight - minHeaderHeight;//Toolbar与header高度的差值
    float offset = 1 - Math.max((headerBarOffsetY - scrollY) / headerBarOffsetY, 0f);
    if(offset == 1){
        mTvTitle.setText(mTitle);
    }else{
        mTvTitle.setText("电影");
    }
    //Toolbar背景色透明度
    mToolBar.setBackgroundColor(Color.argb((int) (offset * 255), 44, 44, 44));
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:16,代码来源:MovieDetailActivity.java

示例3: onScrollChange

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    View lastView = v.getChildAt(v.getChildCount() - 1);
    int lastViewHeight = lastView.getBottom();
    lastViewHeight -= (v.getHeight() + v.getScrollY());
    if (lastViewHeight == 0) {
        if (xNestedScrollViewListener != null) {
            xNestedScrollViewListener.onScrollToPageEnd();
        }
    }
}
 
开发者ID:a396901990,项目名称:Article-Comment,代码行数:12,代码来源:XNestedScrollView.java

示例4: onSelectionStarted

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
public void onSelectionStarted(float x, float y) {
    if (ssReadingActivityBinding != null) {
        LinearLayout view = ssReadingActivityBinding.ssReadingViewPager.findViewWithTag("ssReadingView_"+ssReadingActivityBinding.ssReadingViewPager.getCurrentItem());
        NestedScrollView scrollView = view.findViewById(R.id.ss_reading_view_scroll);

        y = y - scrollView.getScrollY() + ssReadingActivityBinding.ssReadingViewPager.getTop();

        DisplayMetrics metrics = new DisplayMetrics();
        ((SSReadingActivity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.getLayoutParams();

        int contextMenuWidth = ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.getWidth();
        int contextMenuHeight = ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.getHeight();


        int screenWidth = metrics.widthPixels;
        int screenHeight = metrics.heightPixels;

        int margin = SSHelper.convertDpToPixels(context, 20);
        int jumpMargin = SSHelper.convertDpToPixels(context, 60);


        int contextMenuX = (int) x - (contextMenuWidth / 2);
        int contextMenuY = scrollView.getTop() + (int) y - contextMenuHeight - margin;

        if (contextMenuX - margin < 0) {
            contextMenuX = margin;
        }

        if (contextMenuX + contextMenuWidth + margin > screenWidth) {
            contextMenuX = screenWidth - margin - contextMenuWidth;
        }

        if (contextMenuY - margin < 0) {
            contextMenuY = contextMenuY + contextMenuHeight + jumpMargin;
        }

        params.setMargins(contextMenuX, contextMenuY, 0, 0);
        ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.setLayoutParams(params);
        ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.setVisibility(View.VISIBLE);
        highlightId = 0;
    }
}
 
开发者ID:Adventech,项目名称:sabbath-school-android,代码行数:45,代码来源:SSReadingViewModel.java


注:本文中的android.support.v4.widget.NestedScrollView.getScrollY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。