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


Java AppBarLayout.getTotalScrollRange方法代码示例

本文整理汇总了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;
  }
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:21,代码来源:AppBarStateChangeEvent.java

示例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
        }
    }
 
开发者ID:Yuanhongliang,项目名称:HLOLI,代码行数:19,代码来源:ColumnListActivity.java

示例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;
    }
}
 
开发者ID:GitLqr,项目名称:LQRBiliBlili,代码行数:20,代码来源:AppBarStateChangeEvent.java

示例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));
        }
    }
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:18,代码来源:PeopleDetailFragment.java

示例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();
    }
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:25,代码来源:ProfileActivity.java

示例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;
  }
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:19,代码来源:AppBarStateChangeListener.java

示例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();
    }
}
 
开发者ID:codenergic,项目名称:theskeleton-ui-android,代码行数:23,代码来源:ProfileActivity.java

示例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;
    }
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:20,代码来源:AppBarStateChangeListener.java

示例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);
}
 
开发者ID:FarshidABZ,项目名称:CoordinatorBehavior,代码行数:9,代码来源:HandleProfileViewBehavior.java

示例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; // 中间
        }
    }

}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:31,代码来源:ContentsActivity.java

示例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);
}
 
开发者ID:appteam-nith,项目名称:Nimbus,代码行数:10,代码来源:CoreTeamEventActivity.java

示例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));
}
 
开发者ID:crazysunj,项目名称:CrazyDaily,代码行数:7,代码来源:HomeActivity.java

示例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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:7,代码来源:ViewerFragment.java

示例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));
        }
    }
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:49,代码来源:ChatUserFragment.java

示例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();
}
 
开发者ID:nfdz,项目名称:foco,代码行数:43,代码来源:MainActivity.java


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