怎么获取 CollapsingToolbarLayout 的收缩.来自Fulgens
2个回答
2016-04-30
展开全部
如果是想设置收缩状态:使用下面语句即可
AppBarLayout.setExpanded(boolean);
如果是想获取当前收缩状态,给AppBarLayout设置个OnOffsetChangedListener监听器即可.
private enum State {
EXPANDED,
COLLAPSED,
IDLE
}
private void initViews() {
mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
private State state;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (state != State.EXPANDED) {
...
}
state = State.EXPANDED;
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (state != State.COLLAPSED) {
...
}
state = State.COLLAPSED;
} else {
if (state != State.IDLE) {
...
}
state = State.IDLE;
}
}
});
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询