本文整理了Java中android.support.v4.widget.NestedScrollView.scrollTo()
方法的一些代码示例,展示了NestedScrollView.scrollTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NestedScrollView.scrollTo()
方法的具体详情如下:
包路径:android.support.v4.widget.NestedScrollView
类名称:NestedScrollView
方法名:scrollTo
暂无
代码示例来源:origin: florent37/MaterialViewPager
public static void scrollTo(Object scroll, float yOffset) {
if (scroll instanceof RecyclerView) {
//RecyclerView.scrollTo : UnsupportedOperationException
//Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
//Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
}
} else if (scroll instanceof NestedScrollView) {
((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
}
}
代码示例来源:origin: hidroh/materialistic
@Synthetic
void setFullscreen(boolean isFullscreen) {
if (getView() == null) {
return;
}
mFullscreen = isFullscreen;
mControls.setVisibility(isFullscreen ? VISIBLE : View.GONE);
AppUtils.toggleWebViewZoom(mWebView.getSettings(), isFullscreen);
ViewGroup.LayoutParams params = mWebView.getLayoutParams();
if (isFullscreen) {
mScrollView.removeView(mScrollViewContent);
mWebView.scrollTo(mScrollView.getScrollX(), mScrollView.getScrollY());
mFullscreenView.addView(mScrollViewContent);
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
reset();
// We'll zoom out until it returns false, which means it has min zoom level.
// It's quite dangerous piece of code - potentially could lead to infinite loop,
// so let's add some reasonable limit just in case
int i = 0;
while (mWebView.zoomOut() && i < 30) {
i++;
}
mFullscreenView.removeView(mScrollViewContent);
mScrollView.addView(mScrollViewContent);
mScrollView.post(() -> mScrollView.scrollTo(mWebView.getScrollX(), mWebView.getScrollY()));
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
}
mWebView.setLayoutParams(params);
}
代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK
@Override
public void onChanged(ComplexParamsView view) {
scrollView.scrollTo(0, scrollView.getBottom());
}
});
代码示例来源:origin: AppLozic/Applozic-Android-SDK
@Override
public void run() {
nestedScrollView.scrollTo(nestedScrollView.getLeft(), groupParticipantsTexView.getTop());
}
});
代码示例来源:origin: 6ag/BaoKanAndroid
/**
* 页码发生改变 更新页码指示器和图片描述文字
*
* @param position 页码
*/
private void onPageChanged(int position) {
mPageTextView.setText(position + 1 + "/" + photoBeans.size());
mCaptionTextView.setText(photoBeans.get(position).getCaption());
// 滚动到最顶部
mCaptionScriollView.scrollTo(0, 0);
// 修改文本描述载体scrollView高度
ViewTreeObserver vto = mCaptionTextView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mCaptionTextView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int height = mCaptionTextView.getHeight();
int scrollViewHeight = height + SizeUtils.dip2px(mContext, 45);
int scrollViewMaxHeight = SizeUtils.dip2px(mContext, 120);
// 修改文字载体ScrollView的高度 = mCaptionTextView高度 + 35dp,并且现在最大高度为200dip
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mCaptionScriollView.getLayoutParams();
layoutParams.height = scrollViewHeight < scrollViewMaxHeight ? scrollViewHeight : scrollViewMaxHeight;
mCaptionScriollView.setLayoutParams(layoutParams);
}
});
}
代码示例来源:origin: WangDaYeeeeee/Mysplash
scrollView.scrollTo(0, 0);
scrollView.setOnScrollChangeListener(new OnScrollListener());
photoInfoPresenter.getAdapter().reset(photoInfoPresenter.getPhoto());
内容来源于网络,如有侵权,请联系作者删除!