本文整理汇总了Java中android.support.v4.widget.NestedScrollView类的典型用法代码示例。如果您正苦于以下问题:Java NestedScrollView类的具体用法?Java NestedScrollView怎么用?Java NestedScrollView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NestedScrollView类属于android.support.v4.widget包,在下文中一共展示了NestedScrollView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: viewInitialize
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
public void viewInitialize()
{
mainListView = (ListView) findViewById(R.id.listview);
scrollview = (NestedScrollView) findViewById(R.id.scrollview);
mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("PlayListFragment", i+"/"+l);
global.playMusic(Integer.parseInt(playList.get(i)));
}
});
mainListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
scrollview.requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
示例2: scrollTo
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
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);
}
}
示例3: fling
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean fling(int velocity) {
if (mScrollableView instanceof ScrollView) {
((ScrollView) mScrollableView).fling(velocity);
} else if (mScrollableView instanceof AbsListView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
((AbsListView) mScrollableView).fling(velocity);
}
} else if (mScrollableView instanceof WebView) {
((WebView) mScrollableView).flingScroll(0, velocity);
} else if (mScrollableView instanceof RecyclerView) {
((RecyclerView) mScrollableView).fling(0, velocity);
} else if (mScrollableView instanceof NestedScrollView) {
((NestedScrollView) mScrollableView).fling(velocity);
} else {
return false;
}
return true;
}
示例4: onCreate
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
);
setContentView(R.layout.activity_scroll_and_navigation);
final NestedScrollView nestedScrollView = findViewById(R.id.scrollview);
final AppBarLayout appBarLayout = findViewById(R.id.appbar);
final Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Wow");
ScrimInsetsFrameLayout scrimInsetsFrameLayout = findViewById(R.id.root_insets);
scrimInsetsFrameLayout.setOnInsetsCallback(new OnInsetsCallback() {
@Override
public void onInsetsChanged(Rect insets) {
appBarLayout.setPadding(0, insets.top, 0, 0);
nestedScrollView.setPadding(0, 0, 0, insets.bottom);
}
});
}
示例5: flingCompat
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
public static void flingCompat(View view, int velocityY) {
if (view instanceof ScrollView) {
((ScrollView) view).fling(velocityY);
} else if (view instanceof WebView) {
((WebView) view).flingScroll(0, velocityY);
} else if (view instanceof RecyclerView) {
((RecyclerView) view).fling(0, velocityY);
} else if (view instanceof NestedScrollView) {
((NestedScrollView) view).fling(velocityY);
} else if (view instanceof AbsListView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
((AbsListView) view).fling(velocityY);
} else {
SRReflectUtil.compatOlderAbsListViewFling((AbsListView) view, velocityY);
}
}
}
示例6: onScrollChange
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override public void onScrollChange(NestedScrollView v, int x, int y, int oldx, int oldy) {
if (y <= 0) { //设置标题的背景颜色
llGoodDetail.setBackgroundColor(Color.argb(0, 255, 255, 255));
line.setVisibility(View.GONE);
tvGoodDetailTitleGood.setTextColor(Color.TRANSPARENT);
} else if (y > 0 && y <= height) { //滑动距离小于banner图的高度时,设置背景和字体颜色颜色透明度渐变
float scale = (float) y / height;
float alpha = (255 * scale);
tvGoodDetailTitleGood.setTextColor(Color.argb((int) alpha, 1, 24, 28));
llGoodDetail.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
line.setVisibility(View.GONE);
} else { //滑动到banner下面设置普通颜色
llGoodDetail.setBackgroundColor(Color.argb(255, 255, 255, 255));
line.setVisibility(View.VISIBLE);
}
}
示例7: onNestedFling
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
float velocityX, float velocityY, boolean consumed) {
if (target instanceof RecyclerView && velocityY < 0) {
Log.d(TAG, "onNestedFling: target is recyclerView");
final RecyclerView recyclerView = (RecyclerView) target;
final View firstChild = recyclerView.getChildAt(0);
final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
}
// prevent fling flickering when going up
if (target instanceof NestedScrollView && velocityY > 0) {
consumed = true;
}
if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
}
Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
示例8: initDynamicTitle
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
private void initDynamicTitle() {
mRlTopContainer.measure(0, 0);
mLlTitle.measure(0, 0);
final int topHeight = mRlTopContainer.getMeasuredHeight() - mLlTitle.getMeasuredHeight();
mScStarDetail.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
float scale = (float) v.getScrollY() / topHeight;
//变化范围0-255 表示从透明到纯色背景
float alpha = scale * 255 >= 255 ? 255 : scale * 255;
mLlTitle.setBackgroundColor(Color.argb((int) alpha, 0, 153, 204));
mTvTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
mTvSubTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
}
});
}
示例9: initListener
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
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;
});
}
示例10: initData
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void initData() {
mId = getIntent().getIntExtra(EXTRA_THEME_ID, 0);
final String name = getIntent().getStringExtra(EXTRA_THEME_NAME);
mToolbar.setTitle(name);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mZhihuListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
NestedScrollView.LayoutParams.MATCH_PARENT,
NestedScrollView.LayoutParams.MATCH_PARENT));
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mZhihuListRecyclerView.setLayoutManager(layoutManager);
mZhihuListRecyclerView.setAdapter(mThemeListAdapter);
mPresenter.loadThemesList(mId);
}
示例11: initData
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void initData() {
mColumnAuthorHref = getIntent().getStringExtra(EXTRA_AUTHOR_NAME);
mToolbar.setTitle(null);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mColumnListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
NestedScrollView.LayoutParams.MATCH_PARENT,
NestedScrollView.LayoutParams.MATCH_PARENT));
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mColumnListRecyclerView.setLayoutManager(layoutManager);
mColumnListRecyclerView.setAdapter(mColumnListAdapter);
mPresenter.loadColumnAuthorInfo(mColumnAuthorHref);
mPresenter.loadColumnList(mColumnAuthorHref);
mIsLiked = mPresenter.isZhiHuColumnAuthorLiked(mColumnAuthorHref);
mLikeAuthor.setText(getString(mIsLiked ? R.string.zhihu_followed : R.string.zhihu_follow));
}
示例12: onNestedFling
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
float velocityX, float velocityY, boolean consumed) {
if (target instanceof RecyclerView && velocityY < 0) {
Log.d(TAG, "onNestedFling: target is recyclerView");
final RecyclerView recyclerView = (RecyclerView) target;
final View firstChild = recyclerView.getChildAt(0);
final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
}
// prevent fling flickering when going up
if (target instanceof NestedScrollView && velocityY > 0) {
consumed = true;
}
if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
}
Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
示例13: initViews
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
/**
* This method is to initialize views
*/
private void initViews() {
nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);
textInputLayoutName = (TextInputLayout) findViewById(R.id.textInputLayoutName);
textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
textInputLayoutConfirmPassword = (TextInputLayout) findViewById(R.id.textInputLayoutConfirmPassword);
textInputEditTextName = (TextInputEditText) findViewById(R.id.textInputEditTextName);
textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
textInputEditTextConfirmPassword = (TextInputEditText) findViewById(R.id.textInputEditTextConfirmPassword);
appCompatButtonRegister = (AppCompatButton) findViewById(R.id.appCompatButtonRegister);
appCompatTextViewLoginLink = (AppCompatTextView) findViewById(R.id.appCompatTextViewLoginLink);
}
示例14: initWidgets
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
private void initWidgets() {
View view = LayoutInflater.from(getContext())
.inflate(R.layout.view_tab_picker, this, false);
mRecyclerActive = (RecyclerView) view.findViewById(R.id.view_recycler_active);
mRecyclerInactive = (RecyclerView) view.findViewById(R.id.view_recycler_inactive);
mViewScroller = (NestedScrollView) view.findViewById(R.id.view_scroller);
mLayoutTop = (RelativeLayout) view.findViewById(R.id.layout_top);
mViewWrapper = (LinearLayout) view.findViewById(R.id.view_wrapper);
mViewDone = (TextView) view.findViewById(R.id.tv_done);
mViewOperator = (TextView) view.findViewById(R.id.tv_operator);
mLayoutWrapper = (LinearLayout) view.findViewById(R.id.layout_wrapper);
mViewDone.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mViewDone.getText().toString().equals("排序删除")) {
mActiveAdapter.startEditMode();
} else {
mActiveAdapter.cancelEditMode();
}
}
});
addView(view);
}
示例15: prepareUI
import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
/**
* 准备UI
*/
private void prepareUI() {
mViewPager = (ViewPager) findViewById(R.id.vp_photo_detail_viewPager);
mTopLayout = findViewById(R.id.ll_photo_detail_top_layout);
mPageTextView = (TextView) findViewById(R.id.tv_photo_detail_page);
mReportTextView = (TextView) findViewById(R.id.tv_photo_detail_report);
mProgressBar = (ProgressBar) findViewById(R.id.pb_photo_detail_progressbar);
mBottomLayout = findViewById(R.id.ll_photo_detail_bottom_layout);
mCaptionScriollView = (NestedScrollView) findViewById(R.id.nsv_photo_detail_caption_scrollview);
mCaptionTextView = (TextView) findViewById(R.id.tv_photo_detail_caption);
mBackButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_back);
mEditButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_edit);
mCommentButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_comment);
mCollectionButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_collection);
mShareButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_share);
mPlnumTextView = (TextView) findViewById(R.id.tv_photo_detail_plnum);
// 监听点击事件
mReportTextView.setOnClickListener(this);
mBackButton.setOnClickListener(this);
mEditButton.setOnClickListener(this);
mCommentButton.setOnClickListener(this);
mCollectionButton.setOnClickListener(this);
mShareButton.setOnClickListener(this);
}