本文整理汇总了Java中android.support.design.widget.AppBarLayout.getTotalScrollRange方法的典型用法代码示例。如果您正苦于以下问题:Java AppBarLayout.getTotalScrollRange方法的具体用法?Java AppBarLayout.getTotalScrollRange怎么用?Java AppBarLayout.getTotalScrollRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.AppBarLayout
的用法示例。
在下文中一共展示了AppBarLayout.getTotalScrollRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED, verticalOffset);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED, verticalOffset);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE, verticalOffset);
}
mCurrentState = State.IDLE;
}
}
示例2: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
int a = appBarLayout.getTotalScrollRange();
// Log.e("offset", verticalOffset + "----" + a);
if (verticalOffset == 0) {
//expand all
back.setImageResource(R.drawable.back_black);
} else if (Math.abs(verticalOffset) >= a) {
//closed totally
title.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
back.setImageResource(R.drawable.back_white);
} else {
title.setVisibility(View.GONE);
icon.setVisibility(View.GONE);
//doing the transition
}
}
示例3: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED, verticalOffset);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED, verticalOffset);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE, verticalOffset);
}
mCurrentState = State.IDLE;
}
}
示例4: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) - appBarLayout.getTotalScrollRange() == 0) {
activityTtile.setVisibility(View.VISIBLE);
activityTtile.setText(personName.getText());
toolbar.setBackgroundColor(toolbarColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(Utils.getDarkColor(toolbarColor));
}
} else {
activityTtile.setVisibility(View.GONE);
toolbar.setBackgroundColor(ContextCompat.getColor(activity, android.R.color.transparent));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, android.R.color.transparent));
}
}
}
示例5: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (mMaxScrollSize == 0)
mMaxScrollSize = appBarLayout.getTotalScrollRange();
int percentage = (Math.abs(verticalOffset)) * 100 / mMaxScrollSize;
if (percentage >= PERCENTAGE_TO_ANIMATE_AVATAR && mIsAvatarShown) {
mIsAvatarShown = false;
imgProfile.animate()
.scaleY(0).scaleX(0)
.setDuration(200)
.start();
}
if (percentage <= PERCENTAGE_TO_ANIMATE_AVATAR && !mIsAvatarShown) {
mIsAvatarShown = true;
imgProfile.animate()
.scaleY(1).scaleX(1)
.start();
}
}
示例6: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
if (i == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE);
}
mCurrentState = State.IDLE;
}
}
示例7: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (mMaxScrollSize == 0)
mMaxScrollSize = appBarLayout.getTotalScrollRange();
int percentage = (Math.abs(verticalOffset)) * 100 / mMaxScrollSize;
if (percentage >= PERCENTAGE_TO_ANIMATE_AVATAR && mIsAvatarShown) {
mIsAvatarShown = false;
profileImage.animate()
.scaleY(0).scaleX(0)
.setDuration(200)
.start();
}
if (percentage <= PERCENTAGE_TO_ANIMATE_AVATAR && !mIsAvatarShown) {
mIsAvatarShown = true;
profileImage.animate()
.scaleY(1).scaleX(1)
.start();
}
}
示例8: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
if (i == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE);
}
mCurrentState = State.IDLE;
}
}
示例9: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) {
int maxScroll = appBarLayout.getTotalScrollRange();
float percentage = (float) Math.abs(offset) / (float) maxScroll;
handleAlphaOnTitle(percentage);
handleToolbarTitleVisibility(percentage);
}
示例10: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (appBarState != CollapsingToolbarLayoutState.EXPANDED) {
Log.e("ContentsActivity", "onOffsetChanged: EXPANDED");
refreshLayout.setRefreshEnabled(true);
refreshLayout.setLoadMoreEnabled(false);
if (needRefresh) {
refreshLayout.setRefreshing(true);
needRefresh = false;
}
appBarState = CollapsingToolbarLayoutState.EXPANDED; // 展开
}
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
Log.e("ContentsActivity", "onOffsetChanged: COLLAPSED");
refreshLayout.setLoadMoreEnabled(true);
refreshLayout.setRefreshEnabled(false);
appBarState = CollapsingToolbarLayoutState.COLLAPSED; // 折叠
} else {
if (appBarState != CollapsingToolbarLayoutState.MIDDLE) {
if (appBarState == CollapsingToolbarLayoutState.COLLAPSED) {
Log.e("ContentsActivity", "onOffsetChanged: MIDDLE + COLLAPSED");
}
Log.e("ContentsActivity", "onOffsetChanged: MIDDLE");
appBarState = CollapsingToolbarLayoutState.MIDDLE; // 中间
}
}
}
示例11: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) {
int maxScroll = appBarLayout.getTotalScrollRange();
float percentage = (float) Math.abs(offset) / (float) maxScroll;
handleAlphaOnTitle(percentage);
handleToolbarTitleVisibility(percentage);
}
示例12: handleAppbarOffsetChangedListener
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void handleAppbarOffsetChangedListener(AppBarLayout appBarLayout, int verticalOffset) {
final int totalScrollRange = appBarLayout.getTotalScrollRange();
final float percent = Math.abs(verticalOffset * 1.0f / totalScrollRange);
mRefresh.setEnabled(verticalOffset == 0);
mTitle.setTextColor((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK));
}
示例13: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
verticalOffset = Math.abs(verticalOffset);
if (verticalOffset == 0 || verticalOffset == appBarLayout.getTotalScrollRange())
isAppBarMoving = false;
}
示例14: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
super.onOffsetChanged(appBarLayout, verticalOffset);
View view = mPortrait;
MenuItem menuItem = mUserInfoMenuItem;
if (view == null || menuItem == null) {
return;
}
if (verticalOffset == 0) {
// 完全展开
view.setVisibility(View.VISIBLE);
view.setScaleX(1);
view.setScaleY(1);
view.setAlpha(1);
// 隐藏Menu菜单
menuItem.setVisible(false);
menuItem.getIcon().setAlpha(0);
} else {
// abs运算
verticalOffset = Math.abs(verticalOffset);
final int totalScrollRange = appBarLayout.getTotalScrollRange();
if (verticalOffset >= totalScrollRange) {
// 关闭状态
view.setVisibility(View.INVISIBLE);
view.setScaleX(0);
view.setScaleY(0);
view.setAlpha(0);
// 显示菜单
menuItem.setVisible(true);
menuItem.getIcon().setAlpha(255);
} else {
// 中间状态
float progress = 1 - verticalOffset / (float) totalScrollRange;
view.setScaleX(progress);
view.setScaleY(progress);
view.setAlpha(progress);
// 和头像恰好相反
menuItem.setVisible(true);
menuItem.getIcon().setAlpha(255 - (int) (255 * progress));
}
}
}
示例15: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) {
int maxScroll = appBarLayout.getTotalScrollRange();
float percentage = (float) Math.abs(offset) / (float) maxScroll;
// update logo
if (percentage < PERCENTAGE_LOGO_THRESHOLD) {
if (mToolbarLogoVisible) {
startAlphaAnimation(mToolbarLogo, ALPHA_ANIMATIONS_DURATION, View.INVISIBLE);
mToolbarLogoVisible = false;
}
if (!mLayoutLogoVisible) {
startAlphaAnimation(mLayoutLogo, ALPHA_ANIMATIONS_DURATION, View.VISIBLE);
mLayoutLogoVisible = true;
}
} else {
if (!mToolbarLogoVisible) {
startAlphaAnimation(mToolbarLogo, ALPHA_ANIMATIONS_DURATION, View.VISIBLE);
mToolbarLogoVisible = true;
}
if (mLayoutLogoVisible) {
startAlphaAnimation(mLayoutLogo, ALPHA_ANIMATIONS_DURATION, View.INVISIBLE);
mLayoutLogoVisible = false;
}
}
// update add doc adapter placeholder
if (percentage < PERCENTAGE_ADD_DOC_THRESHOLD) {
if (mAdapter.getShowAddDoc()) {
mAdapter.setShowAddDoc(false);
}
} else {
if (!mAdapter.getShowAddDoc()) {
mAdapter.setShowAddDoc(true);
}
}
// It is necessary to make sure that the toolbar is in the front because in some
// versions of android (not all :S) the collapsible layout is placed above the toolbar
// when it is expanding
mToolbar.bringToFront();
}