當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。