Search in sources :

Example 21 with AppBarLayout

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;
}
Also used : AppBarLayout(android.support.design.widget.AppBarLayout) View(android.view.View)

Example 22 with AppBarLayout

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);
            }
        }
    });
}
Also used : AppBarStateChangeEvent(com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent) AppBarLayout(android.support.design.widget.AppBarLayout) ActionBar(android.support.v7.app.ActionBar) TextPaint(android.text.TextPaint)

Example 23 with AppBarLayout

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);
    }
}
Also used : ViewParent(android.view.ViewParent) AppBarLayout(android.support.design.widget.AppBarLayout)

Example 24 with AppBarLayout

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();
}
Also used : ViewParent(android.view.ViewParent) AppBarLayout(android.support.design.widget.AppBarLayout)

Example 25 with AppBarLayout

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;
                }
            });
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) AppBarStateChangeListener(com.d.lib.xrv.listener.AppBarStateChangeListener) ViewParent(android.view.ViewParent) ListState(com.d.lib.xrv.view.ListState) AppBarLayout(android.support.design.widget.AppBarLayout) IRecyclerView(com.d.lib.xrv.listener.IRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

AppBarLayout (android.support.design.widget.AppBarLayout)27 View (android.view.View)15 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)11 RecyclerView (android.support.v7.widget.RecyclerView)7 Intent (android.content.Intent)6 ViewGroup (android.view.ViewGroup)6 ImageView (android.widget.ImageView)6 TabLayout (android.support.design.widget.TabLayout)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 Toolbar (android.support.v7.widget.Toolbar)5 TextView (android.widget.TextView)5 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)4 ViewPager (android.support.v4.view.ViewPager)4 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)4 PagerAdapter (android.support.v4.view.PagerAdapter)3 NestedScrollView (android.support.v4.widget.NestedScrollView)3 ActionBar (android.support.v7.app.ActionBar)3 ViewParent (android.view.ViewParent)3 Activity (android.app.Activity)2 Bundle (android.os.Bundle)2