Search in sources :

Example 11 with AppBarLayout

use of com.google.android.material.appbar.AppBarLayout in project IITB-App by wncc.

the class EventFragment method setupAppBarLayout.

/**
 * Initialize app bar layout
 */
private void setupAppBarLayout() {
    // Set the behavior
    AppBarLayout mAppBarLayout = getView().findViewById(R.id.appBar);
    ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).setBehavior(new AppBarLayout.Behavior());
    // Set offset on init
    mAppBarLayout.post(() -> setAppBarOffset(appBarOffset));
    // Store offset for next init
    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
            if (i != 0)
                appBarOffset = -i;
        }
    });
}
Also used : AppBarLayout(com.google.android.material.appbar.AppBarLayout) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 12 with AppBarLayout

use of com.google.android.material.appbar.AppBarLayout in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FloatingAppBarScrollingViewBehaviorTest method setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent.

@Test
public void setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent() {
    mContext.setTheme(R.style.Theme_Settings_Home);
    final AppBarLayout appBarLayout = new AppBarLayout(mContext);
    appBarLayout.setBackgroundColor(Color.WHITE);
    mScrollingViewBehavior.setAppBarLayoutTransparent(appBarLayout);
    assertThat(((ColorDrawable) appBarLayout.getBackground()).getColor()).isEqualTo(Color.TRANSPARENT);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) AppBarLayout(com.google.android.material.appbar.AppBarLayout) Test(org.junit.Test)

Example 13 with AppBarLayout

use of com.google.android.material.appbar.AppBarLayout in project android_packages_apps_Settings by omnirom.

the class FloatingAppBarScrollingViewBehavior method onDependentViewChanged.

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    boolean changed = super.onDependentViewChanged(parent, child, dependency);
    if (!initialized && dependency instanceof AppBarLayout) {
        initialized = true;
        AppBarLayout appBarLayout = (AppBarLayout) dependency;
        setAppBarLayoutTransparent(appBarLayout);
    }
    return changed;
}
Also used : AppBarLayout(com.google.android.material.appbar.AppBarLayout)

Example 14 with AppBarLayout

use of com.google.android.material.appbar.AppBarLayout in project android_packages_apps_Settings by omnirom.

the class HomepageAppBarScrollingViewBehavior method onDependentViewChanged.

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    boolean changed = super.onDependentViewChanged(parent, child, dependency);
    if (!mInitialized && dependency instanceof AppBarLayout) {
        mInitialized = true;
        AppBarLayout appBarLayout = (AppBarLayout) dependency;
        setAppBarLayoutTransparent(appBarLayout);
    }
    return changed;
}
Also used : AppBarLayout(com.google.android.material.appbar.AppBarLayout)

Example 15 with AppBarLayout

use of com.google.android.material.appbar.AppBarLayout in project android_packages_apps_Settings by omnirom.

the class HomepageAppBarScrollingViewBehaviorTest method setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent.

@Test
public void setAppBarLayoutTransparent_backgroundDefaultAsWhite_shouldBeTransparent() {
    mContext.setTheme(R.style.Theme_Settings_Home);
    final AppBarLayout appBarLayout = new AppBarLayout(mContext);
    appBarLayout.setBackgroundColor(Color.WHITE);
    mScrollingViewBehavior.setAppBarLayoutTransparent(appBarLayout);
    assertThat(((ColorDrawable) appBarLayout.getBackground()).getColor()).isEqualTo(Color.TRANSPARENT);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) AppBarLayout(com.google.android.material.appbar.AppBarLayout) Test(org.junit.Test)

Aggregations

AppBarLayout (com.google.android.material.appbar.AppBarLayout)15 View (android.view.View)5 CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)5 ColorDrawable (android.graphics.drawable.ColorDrawable)4 CollapsingToolbarLayout (com.google.android.material.appbar.CollapsingToolbarLayout)4 Test (org.junit.Test)4 Context (android.content.Context)3 Nullable (androidx.annotation.Nullable)3 Handler (android.os.Handler)2 ViewGroup (android.view.ViewGroup)2 Window (android.view.Window)2 WeakReference (java.lang.ref.WeakReference)2 TargetApi (android.annotation.TargetApi)1 Activity (android.app.Activity)1 BroadcastReceiver (android.content.BroadcastReceiver)1 ContentResolver (android.content.ContentResolver)1 ContentUris (android.content.ContentUris)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1