android.support.design.widget.AppBarLayout Java Examples

The following examples show how to use android.support.design.widget.AppBarLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppBarStateChangeListener.java    From LazyRecyclerAdapter with MIT License 6 votes vote down vote up
@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;
    }
}
 
Example #2
Source File: AppBarLayoutAction.java    From espresso-macchiato with MIT License 6 votes vote down vote up
public static ViewAction expand() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(AppBarLayout.class);
        }

        @Override
        public String getDescription() {
            return "Expand AppBarLayout inside of a CollapsingToolbarLayout.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            appBarLayout.setExpanded(true, false);
        }
    };
}
 
Example #3
Source File: AppBarStateChangeListener.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #4
Source File: BaseBehavior.java    From smooth-app-bar-layout with Apache License 2.0 6 votes vote down vote up
private void initScrollTarget(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) {
  Utils.log("initScrollTarget | %b", vScrollTarget != null);
  if (vScrollTarget != null) {
    long tag = getViewTag(vScrollTarget, true);
    if (!mScrollTargets.contains(tag)) {
      mScrollTargets.add(tag);
      OnScrollListener listener = new OnScrollListener() {

        @Override
        public void onScrollChanged(View view, int x, int y, int dx, int dy, boolean accuracy) {
          if (view == vScrollTarget) {
            BaseBehavior.this.onScrollChanged(coordinatorLayout, child, view, y, dy, accuracy);
          }
        }
      };
      if (vScrollTarget instanceof NestedScrollView) {
        ObservableNestedScrollView.newInstance((NestedScrollView) vScrollTarget, mOverrideOnScrollListener, listener);
      } else if (vScrollTarget instanceof RecyclerView) {
        ObservableRecyclerView.newInstance((RecyclerView) vScrollTarget, listener);
      }
    }
  }
}
 
Example #5
Source File: StatusBarCompatLollipop.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static void setStatusBarColorForCollapsingToolbar(Activity activity, AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, int statusColor) {
    Window window = activity.getWindow();
    window.clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
    window.addFlags(Integer.MIN_VALUE);
    window.setStatusBarColor(0);
    window.getDecorView().setSystemUiVisibility(0);
    View mChildView = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                return insets;
            }
        });
        ViewCompat.setFitsSystemWindows(mChildView, true);
        ViewCompat.requestApplyInsets(mChildView);
    }
    ((View) appBarLayout.getParent()).setFitsSystemWindows(true);
    appBarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(true);
    toolbar.setFitsSystemWindows(false);
    collapsingToolbarLayout.setStatusBarScrimColor(statusColor);
}
 
Example #6
Source File: ReadActivity.java    From WanAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBinding(@NonNull ActivityReadBinding binding) {
    binding.includeBar.toolbar.setTitle(mPostBean.getTitle());
    ToolbarHelper.initFullBar(binding.includeBar.toolbar, this);
    FabPopLayoutHelper.initPopLayout(binding.fab, binding.backDrop, binding.layoutBrowse, binding.layoutLike, binding.layoutCopy);

    CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(-1, -1);
    lp.setBehavior(new AppBarLayout.ScrollingViewBehavior());

    mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent(binding.coordinator, 1, lp)
            .useDefaultIndicator(ContextCompat.getColor(ReadActivity.this, R.color.colorAccent), 2)
            .setWebView((WebView) LayoutInflater.from(this).inflate(R.layout.webview, binding.coordinator, false))
            .createAgentWeb()
            .ready()
            .go(mPostBean.getLink());

    if (isNotBlogPost()) {
        binding.cardLike.setVisibility(View.GONE);
        binding.fabLike.setVisibility(View.GONE);
    } else {
        initFab();
    }
}
 
Example #7
Source File: PersonalDelegate.java    From FastWaiMai with MIT License 6 votes vote down vote up
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {

	initView();
	final CollapsingToolbarLayout.LayoutParams layoutParams = (CollapsingToolbarLayout.LayoutParams) mLlToorBarSetting.getLayoutParams();
	mAppbarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
		@Override
		public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
			//TotalScrollRange : 72
			int range = mAppbarLayout.getTotalScrollRange();
			layoutParams.topMargin = Math.abs(verticalOffset) / 2;

			if(verticalOffset != 0&& Math.abs(verticalOffset) != range){
				mLlToorBarSetting.setLayoutParams(layoutParams);
			}
		}
	});
}
 
Example #8
Source File: VideoDetailActivity.java    From LQRBiliBlili with MIT License 6 votes vote down vote up
private void showVideoStartTip() {
    mRlVideoTip.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(mRlVideoTip,
                mIvCover.getWidth() - ArmsUtils.dip2px(VideoDetailActivity.this, mAnchorX),
                mIvCover.getHeight() - ArmsUtils.dip2px(VideoDetailActivity.this, mAnchorY),
                0,
                ((float) Math.hypot(mIvCover.getWidth(), mIvCover.getHeight())));
        circularReveal.setDuration(800);
        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mIvCover.setVisibility(View.GONE);
                mPresenter.loadPlayUrl(aid);
            }
        });
        circularReveal.start();
    } else {
        mPresenter.loadPlayUrl(aid);
    }
    // 锁定AppBarLayout
    AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) mAppbar.getChildAt(0).getLayoutParams();
    layoutParams.setScrollFlags(0);
    mAppbar.getChildAt(0).setLayoutParams(layoutParams);
}
 
Example #9
Source File: AppBarStateChangeEvent.java    From LQRBiliBlili with MIT License 6 votes vote down vote up
@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;
    }
}
 
Example #10
Source File: ReadActivity.java    From FriendBook with GNU General Public License v3.0 6 votes vote down vote up
private void findView() {
    readDrawer = (DrawerLayout) findViewById(R.id.read_drawer);
    readSide = (LinearLayout) findViewById(R.id.read_side);
    readRvSection = (RecyclerView) findViewById(R.id.read_rv_section);
    readView = (PageView) findViewById(R.id.pv_read);
    appBar = (AppBarLayout) findViewById(R.id.appbar);
    readBottom = findViewById(R.id.read_bottom);
    readTvPreChapter = (TextView) findViewById(R.id.read_tv_pre_chapter);
    readSbChapterProgress = (SeekBar) findViewById(R.id.read_sb_chapter_progress);
    readTvNextChapter = (TextView) findViewById(R.id.read_tv_next_chapter);
    readTvCategory = (TextView) findViewById(R.id.read_tv_category);
    readTvNightMode = (TextView) findViewById(R.id.read_tv_night_mode);
    readTvSetting = (TextView) findViewById(R.id.read_tv_setting);
    tvSectionName=findViewById(R.id.tv_section_name);
    readSectionProgress=findViewById(R.id.ll_section_progress);
    readTvSectionProgress=findViewById(R.id.tv_section_progress);
    readSbChapterProgress.setEnabled(false);
}
 
Example #11
Source File: Snackbar.java    From CSnackBar with Apache License 2.0 6 votes vote down vote up
public static void show() {
    if (isCustomView) {
        snackbar.setDuration(snackDuration);
        snackbar.show();
    } else {
        snackbar = android.support.design.widget.Snackbar
                .make(view, snackMessage, snackDuration)
                .setDuration(snackDuration);

        if (isFillParent)
            snackbar.getView().getLayoutParams().width = AppBarLayout.LayoutParams.MATCH_PARENT;

        setTextAlignment(snackbar);

        setColor(colorCode);

        View snackbarView = snackbar.getView();
        TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
        textView.setMaxLines(10);
    }
    snackbar.show();
}
 
Example #12
Source File: BottomBehavior.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) {
    parent.onLayoutChild(child, layoutDirection);
    if (isFirst) {
        isFirst = false;
        if (oLy == 0) {
            oLy = child.getY() + child.getHeight();
        }
        for (int i = 0; i < parent.getChildCount(); i++) {
            View view = parent.getChildAt(i);
            if (view instanceof AppBarLayout) {
                height = view.getMeasuredHeight();
                break;
            }
        }

        child.setY(oLy);
    }

    return true;
}
 
Example #13
Source File: AppBarLayoutAction.java    From espresso-macchiato with MIT License 6 votes vote down vote up
public static ViewAction collapse() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(AppBarLayout.class);
        }

        @Override
        public String getDescription() {
            return "Collapse AppBarLayout inside of a CollapsingToolbarLayout.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            appBarLayout.setExpanded(false, false);
        }
    };
}
 
Example #14
Source File: AppBarStateChangeEvent.java    From HeroVideo-master with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #15
Source File: MyAppBarLayout.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int verticalOffsetAbs = Math.abs(verticalOffset);
    int appBarLayoutHeight = appBarLayout.getHeight();

    if (verticalOffset == 0) {
        if (mListener != null) {
            mListener.onAppBarLayoutMove(appBarLayout, verticalOffset, false);
        }
        return;
    } else if (verticalOffset == appBarLayoutHeight) {
        if (mListener != null) {
            mListener.onAppBarLayoutMove(appBarLayout, verticalOffset, true);
        }
        return;
    }

    if (mListener != null) {
        mListener.onAppBarLayoutMove(appBarLayout, verticalOffset, verticalOffsetAbs > appBarLayoutHeight - AndroidUtils.getStatusBarHeight(getContext()));
    }
}
 
Example #16
Source File: BaseBehavior.java    From CollapsingRefresh with Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
	Logw(TAG, "NestedScrollingParent,onNestedPreScroll: dy:" + dy + ",mCurrentOffset:" + mCurrentOffset);
	if (dy != 0) {
		if (dy < 0) {
			// We're scrolling down
			if (!isCurrentScrollTarget(target)) return;
			isNestedPreScroll = true;
			Logd(TAG, "NestedScrollingParent,onNestedPreScroll: isNestedPreScroll=true:");
		} else {
			// We're scrolling up
			if (!isCurrentScrollTarget(target)) return;
			if (mCurrentOffset == -mTotalScrollRange) {
				Loge(TAG, "NestedScrollingParent,onNestedPreScroll: isNestedPreScroll=true:");
				isNestedPreScroll = true;
				return;
			}
			isNestedPreScroll = false;
			Loge(TAG, "NestedScrollingParent,onNestedPreScroll: setTopAndBottomOffset:");
			syncOffset(-dy);
		}
	}
}
 
Example #17
Source File: MyToolBar.java    From MarketAndroidApp with Apache License 2.0 5 votes vote down vote up
@NonNull
private AppBarLayout findParentAppBarLayout() {
    ViewParent parent = this.getParent();
    if (parent instanceof AppBarLayout) {
        return ((AppBarLayout) parent);
    } else if (parent.getParent() instanceof AppBarLayout) {
        return ((AppBarLayout) parent.getParent());
    } else {
        throw new IllegalStateException("Must be inside an AppBarLayout");
    }
}
 
Example #18
Source File: UserActivity.java    From materialup with Apache License 2.0 5 votes vote down vote up
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    int maxScroll = appBarLayout.getTotalScrollRange();
    float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll;

    handleAlphaOnTitle(percentage);
    handleToolbarTitleVisibility(percentage);
}
 
Example #19
Source File: BaseBehavior.java    From CollapsingRefresh with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
							 float velocityX, float velocityY, boolean consumed) {
	Loge(TAG, "NestedScrollingParent,onNestedFling: fling: velocityY = [" + velocityY + "], consumed = [" + consumed + "]");
	if (!isCurrentScrollTarget(target)) return true;
	if (consumed) {
		if (velocityY < 0) {
			this.velocityY = velocityY;
		}
	}
	return true;
}
 
Example #20
Source File: AlipayHomeActivity.java    From LRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    Log.d("lzx", "verticalOffset=" + verticalOffset);
    //720*1080手机 verticalOffset取值范围[0-200]px
    int absVerticalOffset = Math.abs(verticalOffset);//AppBarLayout竖直方向偏移距离px
    int totalScrollRange = appBarLayout.getTotalScrollRange();//AppBarLayout总的距离px
    //背景颜色转化成RGB的渐变色
    int argb = Color.argb(absVerticalOffset, Color.red(mMaskColor), Color.green(mMaskColor), Color.blue(mMaskColor));
    int argbDouble = Color.argb(absVerticalOffset * 2, Color.red(mMaskColor), Color.green(mMaskColor), Color.blue(mMaskColor));
    //appBarLayout上滑一半距离后小图标应该由渐变到全透明
    int title_small_offset = (200 - absVerticalOffset) < 0 ? 0 : 200 - absVerticalOffset;
    int title_small_argb = Color.argb(title_small_offset * 2, Color.red(mMaskColor),
            Color.green(mMaskColor), Color.blue(mMaskColor));
    //appBarLayout上滑不到一半距离
    if (absVerticalOffset <= totalScrollRange / 2) {
        include_toolbar_search.setVisibility(View.VISIBLE);
        include_toolbar_small.setVisibility(View.GONE);
        //为了和下面的大图标渐变区分,乘以2倍渐变
        v_toolbar_search_mask.setBackgroundColor(argbDouble);
    } else {
        include_toolbar_search.setVisibility(View.GONE);
        include_toolbar_small.setVisibility(View.VISIBLE);
        //appBarLayout上滑一半距离后小图标应该由渐变到全透明
        v_toolbar_small_mask.setBackgroundColor(title_small_argb);

    }
    //上滑时遮罩由全透明到半透明
    v_title_big_mask.setBackgroundColor(argb);
}
 
Example #21
Source File: FixedScrollingViewBehavior.java    From Mi-Band with GNU General Public License v2.0 5 votes vote down vote up
private static AppBarLayout findFirstAppBarLayout(List<View> views) {
    int i = 0;

    for (int z = views.size(); i < z; ++i) {
        View view = (View) views.get(i);
        if (view instanceof AppBarLayout) {
            return (AppBarLayout) view;
        }
    }

    return null;
}
 
Example #22
Source File: FooterBarBehavior.java    From coordinated-effort with MIT License 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent,
                               FooterBarLayout child,
                               View dependency) {
    //We are watching changes in the AppBarLayout
    return dependency instanceof AppBarLayout;
}
 
Example #23
Source File: BaseBehavior.java    From CollapsingRefresh with Apache License 2.0 5 votes vote down vote up
protected void dispatchOffsetChanged(AppBarLayout layout, int translationOffset) {
	if (layout instanceof SmoothAppBarLayout) {
		List listeners = ((SmoothAppBarLayout) layout).mOffsetChangedListeners;
		int i = 0;
		for (int z = listeners.size(); i < z; ++i) {
			WeakReference ref = (WeakReference) listeners.get(i);
			AppBarLayout.OnOffsetChangedListener listener = ref != null ? (AppBarLayout.OnOffsetChangedListener) ref.get() : null;
			if (listener != null) {
				listener.onOffsetChanged(layout, translationOffset);
			}
		}
	}
}
 
Example #24
Source File: ToolBarUtil.java    From Android-Architecture with Apache License 2.0 5 votes vote down vote up
/**
 * 向上需要全部滚出屏幕时设置topMargin代替fitsSystemWindows="true"
 *
 * @param toolbar
 */
public static void setStatusBarFits(Toolbar toolbar) {
    if (toolbar == null) return;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (toolbar.getLayoutParams() instanceof AppBarLayout.LayoutParams) {
            AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
            params.topMargin = StatusBarUtil.getStatusBarHeight(toolbar.getContext());
            toolbar.setLayoutParams(params);

            hideNavigationBar((Activity) toolbar.getContext());
        }
    }
}
 
Example #25
Source File: MergedAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public void addView(AppBarLayout parent, View child, int index) {
    if (child instanceof Toolbar) {
        FrameLayout frame = createFrameLayout(parent.getContext());
        mergedView = createMergedView(parent.getContext());
        setMergedBackgroundColor();

        frame.addView(mergedView);
        parent.addView(frame);
        Toolbar toolbar = (Toolbar) child;
        frame.addView(toolbar);
        mergedBehavior.setToolbar(toolbar);
        mergedBehavior.setMergedView(mergedView);
    }
}
 
Example #26
Source File: MainActivity.java    From RealmSearchView with Apache License 2.0 5 votes vote down vote up
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (verticalOffset == 0) {
        // Not collapsed
        if (searchView.getVisibility() == View.VISIBLE) {
            hideSearchView();
        }
    } else {
        // Collapsed
        if (searchView.getVisibility() != View.VISIBLE) {
            showSearchView();
            //setFocusOnSearchView();
        }
    }
}
 
Example #27
Source File: DisableableAppBarLayoutBehavior.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(
        @NonNull final CoordinatorLayout parent,
        @NonNull final AppBarLayout child,
        @NonNull final View directTargetChild,
        @NonNull final View target,
        final int nestedScrollAxes,
        final int type) {
    return mEnabled && super.onStartNestedScroll(
            parent, child, directTargetChild, target, nestedScrollAxes, type);
}
 
Example #28
Source File: MainActivity.java    From Universal-CollapsingTabLayout with Apache License 2.0 5 votes vote down vote up
private void findViews() {
	mToolbar = (Toolbar) findViewById(R.id.toolbar);
	mToolbarTextView = (TextView) findViewById(R.id.toolbar_title);
	mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
	mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
	mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
	mHeaderImageView = (KenBurnsView) findViewById(R.id.imageView_header);
	mContainerView = findViewById(R.id.view_container);

	mViewPager = (ViewPager) findViewById(R.id.viewPager);
}
 
Example #29
Source File: BaseActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void setStatusBarBeforeApi19() {
    if (Build.VERSION.SDK_INT < 21 && Build.VERSION.SDK_INT >= 19) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        AppBarLayout appBarLayout=(AppBarLayout)findViewById(R.id.app_bar);
        // appBarLayout 用于有可折叠标题栏的界面
        if (appBarLayout!=null) {
            appBarLayout.setPadding(0, ThemeUtils.getStatusBarHeight(), 0, 0);
        } else if (mToolbar != null) {
            mToolbar.setPadding(0, ThemeUtils.getStatusBarHeight(), 0, 0);
        }
    }
}
 
Example #30
Source File: FixedScrollingViewBehavior.java    From AwesomeSplash with MIT License 5 votes vote down vote up
private static AppBarLayout findFirstAppBarLayout(List<View> views) {
    int i = 0;

    for(int z = views.size(); i < z; ++i) {
        View view = (View)views.get(i);
        if(view instanceof AppBarLayout) {
            return (AppBarLayout)view;
        }
    }

    return null;
}