Java Code Examples for com.google.android.material.appbar.AppBarLayout#setBackgroundColor()

The following examples show how to use com.google.android.material.appbar.AppBarLayout#setBackgroundColor() . 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: EventActivity.java    From intra42 with Apache License 2.0 6 votes vote down vote up
void setView() {
    layoutLoading.setVisibility(View.GONE);
    layoutOnError.setVisibility(View.GONE);

    CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.toolbar_layout);
    AppBarLayout appBar = findViewById(R.id.app_bar);
    collapsingToolbarLayout.setTitle(event.name);
    if (event.kind != null)
        appBar.setBackgroundColor(event.kind.getColorInt(this));

    if (isFinishing())
        return;

    FragmentManager manager = getSupportFragmentManager();

    if (eventFragment != null)
        manager.beginTransaction().remove(eventFragment).commitNow();

    eventFragment = EventFragment.newInstance(event, false);
    manager.beginTransaction().replace(R.id.fragment_container, eventFragment).commit();
}
 
Example 2
Source File: BrandedActivity.java    From nextcloud-notes with GNU General Public License v3.0 6 votes vote down vote up
public void applyBrandToPrimaryToolbar(@NonNull AppBarLayout appBarLayout, @NonNull Toolbar toolbar) {
    // FIXME Workaround for https://github.com/stefan-niedermann/nextcloud-notes/issues/889
    appBarLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.primary));

    final Drawable overflowDrawable = toolbar.getOverflowIcon();
    if (overflowDrawable != null) {
        overflowDrawable.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP);
        toolbar.setOverflowIcon(overflowDrawable);
    }

    final Drawable navigationDrawable = toolbar.getNavigationIcon();
    if (navigationDrawable != null) {
        navigationDrawable.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP);
        toolbar.setNavigationIcon(navigationDrawable);
    }
}
 
Example 3
Source File: BaseActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
    appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary());
    toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor());
    toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor());
    if (toolbar.getNavigationIcon() != null) {
        toolbar.getNavigationIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
    }
    if (toolbar.getOverflowIcon() != null) {
        toolbar.getOverflowIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
    }
}
 
Example 4
Source File: ThemePreviewActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
    appBarLayout.setBackgroundColor(customTheme.colorPrimary);
    toolbar.setTitleTextColor(customTheme.toolbarPrimaryTextAndIconColor);
    toolbar.setSubtitleTextColor(customTheme.toolbarSecondaryTextColor);
    if (toolbar.getNavigationIcon() != null) {
        toolbar.getNavigationIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
    }
    if (toolbar.getOverflowIcon() != null) {
        toolbar.getOverflowIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
    }
}
 
Example 5
Source File: ScreenStackFragment.java    From react-native-screens with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
  CoordinatorLayout view = new NotifyingCoordinatorLayout(getContext(), this);
  CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(
          LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
  params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
  mScreenView.setLayoutParams(params);
  view.addView(recycleView(mScreenView));

  mAppBarLayout = new AppBarLayout(getContext());
  // By default AppBarLayout will have a background color set but since we cover the whole layout
  // with toolbar (that can be semi-transparent) the bar layout background color does not pay a
  // role. On top of that it breaks screens animations when alfa offscreen compositing is off
  // (which is the default)
  mAppBarLayout.setBackgroundColor(Color.TRANSPARENT);
  mAppBarLayout.setLayoutParams(new AppBarLayout.LayoutParams(
          AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT));
  view.addView(mAppBarLayout);

  if (mShadowHidden) {
    mAppBarLayout.setTargetElevation(0);
  }

  if (mToolbar != null) {
    mAppBarLayout.addView(recycleView(mToolbar));
  }

  return view;
}