use of android.support.design.widget.AppBarLayout in project PocketHub by pockethub.
the class PatchedScrollingViewBehavior method onMeasureChild.
@Override
public boolean onMeasureChild(CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
if (child.getLayoutParams().height == -1) {
List<View> dependencies = parent.getDependencies(child);
if (dependencies.isEmpty()) {
return false;
}
AppBarLayout appBar = findFirstAppBarLayout(dependencies);
if (appBar != null && ViewCompat.isLaidOut(appBar)) {
if (ViewCompat.getFitsSystemWindows(appBar)) {
ViewCompat.setFitsSystemWindows(child, true);
}
int parentHeight = View.MeasureSpec.getSize(parentHeightMeasureSpec);
int height = parentHeight - appBar.getMeasuredHeight();
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
parent.onMeasureChild(child, parentWidthMeasureSpec, widthUsed, heightMeasureSpec, heightUsed);
return true;
}
}
return false;
}
use of android.support.design.widget.AppBarLayout in project bilibili-android-client by HotBitmapGG.
the class UserInfoDetailsActivity method initToolBar.
@Override
public void initToolBar() {
mToolbar.setTitle("");
setSupportActionBar(mToolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
//设置StatusBar透明
SystemBarHelper.immersiveStatusBar(this);
SystemBarHelper.setHeightAndPadding(this, mToolbar);
//设置AppBar展开折叠状态监听
mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeEvent() {
@Override
public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
if (state == State.EXPANDED) {
//展开状态
mCollapsingToolbarLayout.setTitle("");
mLineView.setVisibility(View.VISIBLE);
} else if (state == State.COLLAPSED) {
//折叠状态
mCollapsingToolbarLayout.setTitle(name);
mLineView.setVisibility(View.GONE);
} else {
mCollapsingToolbarLayout.setTitle("");
mLineView.setVisibility(View.VISIBLE);
}
}
});
}
use of android.support.design.widget.AppBarLayout in project AisenWeiBo by wangdan.
the class ProfileCollapsingToolbarLayout method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// Add an OnOffsetChangedListener if possible
final ViewParent parent = getParent();
if (parent instanceof AppBarLayout) {
((AppBarLayout) parent).addOnOffsetChangedListener(innerOffsetChangedListener);
layDetail = findViewById(R.id.layDetail);
layRealDetail = findViewById(R.id.layRealDetail);
toolbar = (Toolbar) findViewById(R.id.toolbar);
appBarLayout = (AppBarLayout) parent;
collapsingToolbarLayout = this;
imgCover = (ImageView) findViewById(R.id.imgCover);
tabLayout = (TabLayout) appBarLayout.findViewById(R.id.tabLayout);
layName = findViewById(R.id.layName);
}
}
use of android.support.design.widget.AppBarLayout in project AisenWeiBo by wangdan.
the class ProfileCollapsingToolbarLayout method onDetachedFromWindow.
@Override
protected void onDetachedFromWindow() {
// Remove our OnOffsetChangedListener if possible and it exists
final ViewParent parent = getParent();
if (parent instanceof AppBarLayout) {
((AppBarLayout) parent).removeOnOffsetChangedListener(innerOffsetChangedListener);
}
super.onDetachedFromWindow();
}
use of android.support.design.widget.AppBarLayout in project xRecyclerViewF by Dsiner.
the class XRecyclerView method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
//解决和CollapsingToolbarLayout冲突的问题
AppBarLayout appBarLayout = null;
ViewParent p = getParent();
while (p != null) {
if (p instanceof CoordinatorLayout) {
break;
}
p = p.getParent();
}
if (p instanceof CoordinatorLayout) {
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) p;
final int childCount = coordinatorLayout.getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
final View child = coordinatorLayout.getChildAt(i);
if (child instanceof AppBarLayout) {
appBarLayout = (AppBarLayout) child;
break;
}
}
if (appBarLayout != null) {
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
@Override
public void onStateChanged(AppBarLayout appBarLayout, State state) {
appbarState = state;
}
});
}
}
}
Aggregations