android.support.v4.widget.NestedScrollView.setOnScrollChangeListener()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中android.support.v4.widget.NestedScrollView.setOnScrollChangeListener()方法的一些代码示例,展示了NestedScrollView.setOnScrollChangeListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NestedScrollView.setOnScrollChangeListener()方法的具体详情如下:
包路径:android.support.v4.widget.NestedScrollView
类名称:NestedScrollView
方法名:setOnScrollChangeListener

NestedScrollView.setOnScrollChangeListener介绍

暂无

代码示例

代码示例来源:origin: florent37/MaterialViewPager

scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

代码示例来源:origin: xinghongfei/LookLook

protected void initData() {
  id = getIntent().getStringExtra("id");
  title = getIntent().getStringExtra("title");
  mImageUrl = getIntent().getStringExtra("image");
  mIZhihuStoryPresenter = new ZhihuStoryPresenterImpl(this);
  mNest.setOnScrollChangeListener(scrollListener);
  if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
    postponeEnterTransition();
    mShot.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
      @Override
      public boolean onPreDraw() {
        mShot.getViewTreeObserver().removeOnPreDrawListener(this);
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
          startPostponedEnterTransition();
        }
        return true;
      }
    });
  }
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

float toolBarHeight = getResources().getDimension(R.dimen.action_bar_default_height);
mNestedScrollView.setNestedScrollingEnabled(true);
mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

代码示例来源:origin: iMeiji/Toutiao

scrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> onHideLoading());

代码示例来源:origin: scwang90/SmartRefreshLayout

scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
  private int lastScrollY = 0;
  private int h = DensityUtil.dp2px(170);

代码示例来源:origin: iMeiji/Toutiao

scrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> onHideLoading());
scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
  View view1 = scrollView.getChildAt(scrollView.getChildCount() - 1);

代码示例来源:origin: xinghongfei/LookLook

mNest.setOnScrollChangeListener(scrollListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  postponeEnterTransition();

代码示例来源:origin: CarGuo/GSYVideoPlayer

webTopLayout.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
  @Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

代码示例来源:origin: florent37/ExpectAnim

scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
  @Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

代码示例来源:origin: CodingBingo/FastReader

private void initViewListener() {
  bookIndexScrollview.setOnScrollChangeListener(this);
  showMenuBtn.setOnClickListener(this);
  goSearchBtn.setOnClickListener(this);
  addLocalFile.setOnClickListener(this);
  feedback.setOnClickListener(this);
  about.setOnClickListener(this);
}

代码示例来源:origin: adgvcxz/Dribbble-MVVM

@BindingAdapter({"scrollYAttrChanged"})
public static void setScrollYListener(NestedScrollView nestedScrollView, InverseBindingListener scrollYAttrChanged) {
  if (scrollYAttrChanged != null) {
    nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
      @Override
      public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        scrollYAttrChanged.onChange();
      }
    });
  }
}

代码示例来源:origin: chendongMarch/LightAdapter

@BindingAdapter(value = {"bindScroll"})
public static void onScrollChangeCommand(
    final NestedScrollView nestedScrollView,
    final NestedScrollView.OnScrollChangeListener onScrollChangeListener) {
  nestedScrollView.setOnScrollChangeListener(onScrollChangeListener);
}

代码示例来源:origin: wzmyyj/ZYMK

@Override
protected void initListener() {
  super.initListener();
  mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
      if (viewList.size() == 0) return;
      View top = viewList.get(0);
      //当距离在[0,maxDistance]变化时,透明度在[0,255之间变化]
      int maxDistance = DensityUtil.dp2px(context, 155) - StatusBarUtil.StatusBarHeight;
      float percent = scrollY * 1f / maxDistance;//百分比
      top.setAlpha(percent);
    }
  });
}

代码示例来源:origin: CoderLengary/WanAndroid

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_timeline_page, container, false);
  initViews(view);
  refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      Log.e("Custom", "onRefresh: " );
      currentPage = INDEX;
      presenter.getArticles(INDEX,true,true);
    }
  });
  //滑动到底部加载下一页
  nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
      if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
        loadMore();
      }
    }
  });
  return view;
}

代码示例来源:origin: CoderLengary/WanAndroid

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_timeline_page, container, false);
  initViews(view);
  //滑动到底部加载下一页
  nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
      if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
        loadMore();
      }
    }
  });
  refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      currentPage = INDEX;
      presenter.getFavoriteArticles(INDEX, true, true);
    }
  });
  return view;
}

代码示例来源:origin: GcsSloop/diycode

scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
  @Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int

代码示例来源:origin: wutq/AndroidModuleDemo

@Override
protected void initView() {
  blockAdapter = new HomeRcyAdapter(mContext, blockList, R.layout.wan_item_of_block_list, this);
  rvBlockList.setLayoutManager(new GridLayoutManager(mContext, 4));
  rvBlockList.setAdapter(blockAdapter);
  articleAdapter = new ArticleAdapter(mContext, articleList, R.layout.wan_item_of_article_list, this);
  rvArticleList.setLayoutManager(new LinearLayoutManager(mContext));
  rvArticleList.setAdapter(articleAdapter);
  rvArticleList.setNestedScrollingEnabled(false);
  refreshLayout.setOnPullRefreshListener(this);
  scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView nestedScrollView, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
      if (scrollY >= PxUtils.getScreenHeight(mContext) / 5) {
        goTop.setVisibility(View.VISIBLE);
      } else if (scrollY < PxUtils.getScreenHeight(mContext) / 5) {
        goTop.setVisibility(View.GONE);
      }
    }
  });
  articleAdapter.setOnTagListener(this);
  onRefresh();
}

代码示例来源:origin: guanpj/JReadHub

@Override
public void initDataAndEvent() {
  mToolbar.setNavigationOnClickListener(v -> pop());
  mToolbar.setOnMenuItemClickListener(this);
  mTimelineAdapter = new TopicTimelineAdapter(getContext());
  mRecyclerTimeline.setAdapter(mTimelineAdapter);
  mRecyclerTimeline.setLayoutManager(new LinearLayoutManager(getContext()));
  mRecyclerTimeline.setNestedScrollingEnabled(false);
  mScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
    if (scrollY > mTxtTopicTime.getBottom()) {
      mToolbarHeader.setVisibility(View.VISIBLE);
      mToolbar.setTitle("");
    } else {
      mToolbarHeader.setVisibility(View.GONE);
      mToolbar.setTitle(getText(R.string.menu_topic_detail));
    }
  });
}

代码示例来源:origin: fodroid/XStatusBarHelper

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_two);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
      toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          finish();
        }
      });
    }
    XStatusBarHelper.forceFitsSystemWindows(this);
    XStatusBarHelper.immersiveStatusBar(this);
    XStatusBarHelper.setHeightAndPadding(this, toolbar);

    NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.scrollView);
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
      @Override
      public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        int color = getResources().getColor(R.color.colorPrimary);
        toolbar.setBackgroundColor(Color.argb(scrollY > 255 ? 255 : scrollY, Color.red(color), Color.green
            (color), Color.blue(color)));
      }
    });
  }
}

代码示例来源:origin: zhao-mingjian/qvod

private void initListener() {
  //finish
  getView().toolBar.setNavigationOnClickListener(view -> getView().onBackPressed());
  //
  getView().nsvTitle.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
      scrollChangeHeader(scrollY);
    }
  });
  getView().llLoading.setOnReloadListener(v -> {
    if (JUtils.isNetWorkAvilable())
      //onClick
      initData();
  });
  getView().toolBar.setOnMenuItemClickListener(item -> {
    if (item.getItemId() == R.id.actionbar_more) {
      WebViewActivity.startAction(getView(), positionData.getAlt());
    }
    return false;
  });
}

相关文章