Last active
December 29, 2015 12:29
-
-
Save goodev/7671283 to your computer and use it in GitHub Desktop.
ListView 滚动的时候更新 ActionBar 的 alpha 值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mListView.setOnScrollListener(new AbsListView.OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(AbsListView view, int scrollState) { | |
} | |
@Override | |
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { | |
float ratio = clamp(mHeader.getTranslationY() / mMinHeaderTranslation, 0.0f, 1.0f); | |
//actionbar title alpha | |
getActionBarTitleView().setAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F)); | |
} | |
}); | |
public static float clamp(float value, float max, float min) { | |
return Math.max(Math.min(value, min), max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment