Java 类android.support.design.widget.AppBarLayout 实例源码

项目:HeroVideo-master    文件:AppBarStateChangeEvent.java   
@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;
  }
}
项目:Nibo    文件:ScrollAwareFABBehavior.java   
/**
 * Define one of the point in where the FAB should be hide when it reachs that point.
 * @param coordinatorLayout container of BottomSheet and AppBarLayout
 */
private void setOffsetValue(CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof AppBarLayout) {

            if (child.getTag() != null &&
                    child.getTag().toString().contentEquals("modal-appbar") ) {
                offset = child.getY()+child.getHeight();
                break;
            }
        }
    }
}
项目:UiLib    文件:AppBarStateChangeListener.java   
@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;
    }
}
项目:LineAnimation    文件:DetailActivity.java   
@Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        if (!TextUtils.isEmpty(subTitle)) {
            float value = appBar.getHeight() - toolbar.getHeight() * 2;
            float p = (value + verticalOffset) / value;
            if (p < 0) {
                p = 0;
            }
            subtitleView.setPercent(p);
        }

//        if (Math.abs(verticalOffset) > appBarLayout.getHeight() / 2) {
//            int color = getResources().getColor(R.color.colorPrimary);
//            titleTextView.setTextColor(color);
//            toolbar.getNavigationIcon().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
//        } else {
//            int white = getResources().getColor(R.color.white);
//            toolbar.getNavigationIcon().setColorFilter(white, PorterDuff.Mode.MULTIPLY);
//            titleTextView.setTextColor(white);
//        }

    }
项目:dhbw-timetable-android    文件:NotificationsFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.content_notifications, container, false);

    AppBarLayout appBarLayout = getActivity().findViewById(R.id.appbar);

    if (appBarLayout.getChildCount() == 1) {
        mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());

        mViewPager = rootView.findViewById(R.id.tab_container);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        mTabLayout = new TabLayout(getActivity());
        mTabLayout.setTabTextColors(
                getResources().getColor(R.color.disabledGrey),
                getResources().getColor(R.color.white)
        );
        mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        mTabLayout.setupWithViewPager(mViewPager);

        appBarLayout.addView(mTabLayout);
    }

    return rootView;
}
项目:HLOLI    文件:ColumnListActivity.java   
@Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        int a = appBarLayout.getTotalScrollRange();
//        Log.e("offset", verticalOffset + "----" + a);
        if (verticalOffset == 0) {
            //expand all
            back.setImageResource(R.drawable.back_black);
        } else if (Math.abs(verticalOffset) >= a) {
            //closed totally
            title.setVisibility(View.VISIBLE);
            icon.setVisibility(View.VISIBLE);
            back.setImageResource(R.drawable.back_white);
        } else {
            title.setVisibility(View.GONE);
            icon.setVisibility(View.GONE);
            //doing the transition
        }
    }
项目:Tribe    文件:PersonalHomeActivity.java   
/**
 * 初始化toolbar
 */
private void initToolBar(){
    mAppBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
    //设置导航图标要在setSupportActionBar方法之后
    mToolbar=(Toolbar)findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    //这里必须设置一个空标题,不然toolbar中的textview标题不居中
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int menuItemId = item.getItemId();
            if (menuItemId == R.id.action_more) {
                Toast.makeText(PersonalHomeActivity.this, "举报", Toast.LENGTH_SHORT).show();
            }
            return true;
        }
    });
    mToolbar.setNavigationIcon(R.drawable.white_back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
}
项目:IdeaTrackerPlus    文件:MainActivity.java   
private void disableSearchMode() {
    if (searchMode) {
        searchMode = false;

        //display tabs again
        AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar);
        appbar.removeView(tabLayout); //make sure we're not adding the tabLayout while it's already there
        appbar.addView(tabLayout);
        //display floating button
        mFab.setVisibility(View.VISIBLE);

        //hide searchbar
        mSearchBar.setVisibility(View.GONE);

        //refresh the fragment display
        mViewPager.setAdapter(null);
        mViewPager.setAdapter(mSectionsPagerAdapter);
    }
}
项目:MultiTypeRecyclerViewAdapter    文件:NormalActivity.java   
private void initBar() {

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
        }
        mToolbar.setNavigationIcon(R.mipmap.ic_scan);
        mToolbar.setNavigationOnClickListener(v -> SnackBarUtil.show(NormalActivity.this, "哥,别扫了"));
        mNavigationIcon = mToolbar.getNavigationIcon();
        mAppBar.addOnOffsetChangedListener((AppBarLayout appBarLayout, int verticalOffset) -> {
            int totalScrollRange = appBarLayout.getTotalScrollRange();
            float percent = Math.abs(verticalOffset * 1.0f / totalScrollRange);
            if (mNavigationIcon != null) {
                mNavigationIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
            }
            if (mSearchItemIcon != null) {
                mSearchItemIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
            }
            mTitle.setTextColor((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK));
        });
    }
项目:MovieApp    文件:PeopleDetailFragment.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (Math.abs(verticalOffset) - appBarLayout.getTotalScrollRange() == 0) {
        activityTtile.setVisibility(View.VISIBLE);
        activityTtile.setText(personName.getText());
        toolbar.setBackgroundColor(toolbarColor);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            activity.getWindow().setStatusBarColor(Utils.getDarkColor(toolbarColor));
        }
    } else {
        activityTtile.setVisibility(View.GONE);
        toolbar.setBackgroundColor(ContextCompat.getColor(activity, android.R.color.transparent));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, android.R.color.transparent));
        }
    }
}
项目:Expert-Android-Programming    文件:ScrollFlag.java   
public ScrollFlag(AppBarLayout layout) {
  if (layout != null) {
    int i = 0;
    for (int z = layout.getChildCount(); i < z; ++i) {
      View child = layout.getChildAt(i);
      ViewGroup.LayoutParams layoutParams = child.getLayoutParams();
      if (layoutParams instanceof AppBarLayout.LayoutParams) {
        AppBarLayout.LayoutParams childLp = (AppBarLayout.LayoutParams) layoutParams;
        int flags = childLp.getScrollFlags();
        if ((flags & AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL) != 0) {
          vView = child;
          mFlags = flags;
          break;
        }
      }
    }
  }
}
项目:Programmers    文件:ProfileActivity.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (mMaxScrollSize == 0)
        mMaxScrollSize = appBarLayout.getTotalScrollRange();

    int percentage = (Math.abs(verticalOffset)) * 100 / mMaxScrollSize;

    if (percentage >= PERCENTAGE_TO_ANIMATE_AVATAR && mIsAvatarShown) {
        mIsAvatarShown = false;

        imgProfile.animate()
                .scaleY(0).scaleX(0)
                .setDuration(200)
                .start();
    }

    if (percentage <= PERCENTAGE_TO_ANIMATE_AVATAR && !mIsAvatarShown) {
        mIsAvatarShown = true;

        imgProfile.animate()
                .scaleY(1).scaleX(1)
                .start();
    }
}
项目:MultiTypeRecyclerViewAdapter    文件:AppBarLayoutOverScrollViewBehavior.java   
private void scale(AppBarLayout abl, View target, int dy) {
    mTotalDy += -dy;
    mTotalDy = Math.min(mTotalDy, TARGET_HEIGHT);
    mLastScale = Math.max(1f, 1f + mTotalDy / TARGET_HEIGHT);
    mTargetView.setScaleX(mLastScale);
    mTargetView.setScaleY(mLastScale);
    mLastBottom = mParentHeight + (int) (mTargetViewHeight / 2 * (mLastScale - 1));
    abl.setBottom(mLastBottom);
    target.setScrollY(0);
}
项目:ScrimInsetsLayout    文件:ToolbarActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    setContentView(R.layout.activity_toolbar);

    final AppBarLayout appBarLayout = findViewById(R.id.appbar);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("Wow");

    ScrimInsetsFrameLayout scrimInsetsFrameLayout = findViewById(R.id.root_insets);
    scrimInsetsFrameLayout.setOnInsetsCallback(new OnInsetsCallback() {
        @Override
        public void onInsetsChanged(Rect insets) {
            appBarLayout.setPadding(0, insets.top, 0, 0);
        }
    });
}
项目:dhbw-timetable-android    文件:TodayFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    AppBarLayout appBarLayout = getActivity().findViewById(R.id.appbar);

    if (appBarLayout.getChildCount() != 1) {
        appBarLayout.removeViewAt(1);
    }

    final View view = inflater.inflate(R.layout.content_today, container, false);
    recyclerView = view.findViewById(R.id.recyclingAgenda);

    aAdapter = new AgendaAppointmentAdapter(agendaAppointmentSet);
    RecyclerView.LayoutManager aLayoutManager = new LinearLayoutManager(view.getContext()) {
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    };
    recyclerView.setLayoutManager(aLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(aAdapter);
    return view;
}
项目:CommonsLab    文件:MainActivity.java   
private void setupCollapsingImage() {
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);

    //Fade out CollapsingToolbarLayout title ...from white to transparent
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    Typeface type = Typeface.createFromAsset(getAssets(), "fonts/open_sans/OpenSans-Light.ttf");
    collapsingToolbarLayout.setExpandedTitleTypeface(type);//fonts
    collapsingToolbarLayout.setCollapsedTitleTypeface(type);

    collapsingToolbarLayout.setTitle(getString(R.string.pod));
    collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.white_opacity));
    collapsingToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.white_opacity_king));

    //Set Picture of the day to collapsing ImageView
    collapsingImageView = (ImageView) findViewById(R.id.collapsing_ImageView);

    pictureOfTheDayList = storage.retrieveRSS_Feed(MediaType.PICTURE);
    if (pictureOfTheDayList != null &&
            pictureOfTheDayList.size() > 0 &&
            pictureOfTheDayList.get(0) != null &&
            pictureOfTheDayList.get(0).getMediaLink() != null)
        Glide.with(this)
                .load(pictureOfTheDayList.get(0).getMediaLink())
                .centerCrop()
                .into(collapsingImageView);
}
项目:Pocket-Plays-for-Twitch    文件:ChannelActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_streamer_info);

    // Get the various handles of view and layouts that is part of this view
    streamerImage           = (ImageView) findViewById(R.id.profileImageView);
    additionalInfoLayout    = (LinearLayout) findViewById(R.id.additional_info_wrapper);
    streamerInfoName        = (TextView) findViewById(R.id.twitch_name);
    streamerViewers         = (TextView) findViewById(R.id.txt_viewers);
    streamerFollowers       = (TextView) findViewById(R.id.txt_followers);
    toolbar                 = (Toolbar) findViewById(R.id.StreamerInfo_Toolbar);
    additionalToolbar       = (Toolbar) findViewById(R.id.additional_toolbar);
    mViewPager              = (ViewPager) findViewById(R.id.container);
    mTabs                   = (TabLayout) findViewById(R.id.tabs);
    mAppBar                 = (AppBarLayout) findViewById(R.id.appbar);
    mFab                    = (FloatingActionButton) findViewById(R.id.fab);

    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    // Get the StreamerInfo object sent with the intent to open this activity
    Intent intent = getIntent();
    info = intent.getParcelableExtra(getResources().getString(R.string.channel_info_intent_object));

    streamerInfoName        .setText(info.getDisplayName());
    streamerFollowers       .setText(getReadableInt(info.getFollowers()));
    streamerViewers         .setText(getReadableInt(info.getViews()));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        streamerImage.setTransitionName(getString(R.string.streamerInfo_transition));
    }

    setUpTabs();
    initStreamerImageAndColors();
    initiateFAB();
}
项目:OSchina_resources_android    文件:OtherUserHomeActivity.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (mScrollRange == -1) {
        mScrollRange = appBarLayout.getTotalScrollRange();
    }
    if (mScrollRange + verticalOffset == 0) {
        mLogoNick.setVisibility(View.VISIBLE);
        mLogoPortrait.setVisibility(View.VISIBLE);
        mDivider.setVisibility(View.GONE);
        isShow = true;
    } else if (isShow) {
        mLogoNick.setVisibility(View.GONE);
        mLogoPortrait.setVisibility(View.GONE);
        mDivider.setVisibility(View.VISIBLE);
        isShow = false;
    }
    mTabLayout.getBackground().setAlpha(Math.round(255 - Math.abs(verticalOffset) / (float) mScrollRange * 255));
}
项目:CrazyDaily    文件:AppBarLayoutOverScrollViewBehavior.java   
private void scale(AppBarLayout abl, View target, int dy) {
    mTotalDy += -dy;
    mTotalDy = Math.min(mTotalDy, TARGET_HEIGHT);
    mLastScale = Math.max(1f, 1f + mTotalDy / TARGET_HEIGHT);
    mTargetView.setScaleX(mLastScale);
    mTargetView.setScaleY(mLastScale);
    mLastBottom = mParentHeight + (int) (mTargetViewHeight / 2 * (mLastScale - 1));
    abl.setBottom(mLastBottom);
    target.setScrollY(0);
}
项目:MultiTypeRecyclerViewAdapter    文件:MainActivity.java   
private void initBar() {

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
        }
        mToolbar.setNavigationIcon(R.mipmap.ic_scan);
        mToolbar.setNavigationOnClickListener(v -> SnackBarUtil.show(MainActivity.this, "哥,别扫了"));
        mNavigationIcon = mToolbar.getNavigationIcon();
        mAppBar.addOnOffsetChangedListener((AppBarLayout appBarLayout, int verticalOffset) -> {
            int totalScrollRange = appBarLayout.getTotalScrollRange();
            float percent = Math.abs(verticalOffset * 1.0f / totalScrollRange);
            if (mNavigationIcon != null) {
                mNavigationIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
            }
            if (mSearchItemIcon != null) {
                mSearchItemIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
            }
            mTitle.setTextColor((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK));
        });
    }
项目:BilibiliClient    文件:AppBarStateChangeEvent.java   
@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;
  }
}
项目:TPlayer    文件:OtherUserHomeActivity.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    if (mScrollRange == -1) {
        mScrollRange = appBarLayout.getTotalScrollRange();
    }
    if (mScrollRange + verticalOffset == 0) {
        tv_logo_nick.setVisibility(View.VISIBLE);
        iv_logo_head.setVisibility(View.VISIBLE);
        view_divider.setVisibility(View.GONE);

        isShow = true;
    } else if (isShow) {
        tv_logo_nick.setVisibility(View.GONE);
        iv_logo_head.setVisibility(View.GONE);
        view_divider.setVisibility(View.VISIBLE);

        isShow = false;
    }
    mTabLayout.getBackground().setAlpha(Math.round(255 - Math.abs(verticalOffset) / (float) mScrollRange * 255));
}
项目:Lunary-Ethereum-Wallet    文件:AppBarStateChangeListener.java   
@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;
    }
}
项目:MusicX-music-player    文件:BaseActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(setLayout());
    setUi();
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null && appBarLayout != null) {
        setSupportActionBar(toolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }
    }
    updateTime = System.currentTimeMillis();
    fontConfig();
    function();
    themeConfig();
}
项目:Mixtape    文件:CoordinatedMixtapeContainer.java   
/**
 * Applies the supplied scroll flags to the header.
 *
 * @param flags
 *      the flags to apply, 0 to clear all flags
 */
private void setHeaderScrollFlags(final int flags) {
    final AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) header
            .getLayoutParams();
    layoutParams.setScrollFlags(flags);
    header.setLayoutParams(layoutParams);
}
项目:EasyReader    文件:MovieTopDetailActivity.java   
@Override
protected void initUI() {
    final AppBarLayout appbarMovieTopChild = (AppBarLayout) findViewById(R.id.appbar_movie_top_child);
    ivBaseTitlebarBg = (ImageView) findViewById(R.id.img_item_bg);
    ivOnePhoto = (ImageView) findViewById(R.id.iv_one_photo);
    tvOneRatingRate = (TextView) findViewById(R.id.tv_one_rating_rate);
    tvOneRatingNumber = (TextView) findViewById(R.id.tv_one_rating_number);
    tvOneGenres = (TextView) findViewById(R.id.tv_one_genres);
    tvOneDay = (TextView) findViewById(R.id.tv_one_day);
    tvOneCity = (TextView) findViewById(R.id.tv_one_city);
    tvFormerly = (TextView) findViewById(R.id.tv_formerly);
    toolbarDoubanDetail = (Toolbar) findViewById(R.id.toolbar_douban_detail);
    initToolBar(toolbarDoubanDetail, "");
    appbarMovieTopChild.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (appbarMovieTopChild.getBottom() > toolbarDoubanDetail.getBottom() ) {
                toolbarDoubanDetail.setBackgroundColor(getResources().getColor(R.color.translucent));
            } else {
                toolbarDoubanDetail.setBackgroundResource(R.color.colorTheme);
            }
        }
    });
    subjectsBean = (HotMovieBean.SubjectsBean) getIntent().getSerializableExtra("bean");
    if (subjectsBean != null) {
        toolbarDoubanDetail.setTitle(subjectsBean.getTitle());
        toolbarDoubanDetail.setSubtitleTextColor(Color.WHITE);
        setImgHeaderBg(subjectsBean.getImages().getMedium());
        GlideUtils.loadMovieTopImg(ivOnePhoto, subjectsBean.getImages().getLarge());
        tvOneRatingRate.setText("评分:" + subjectsBean.getRating().getAverage());
        tvOneGenres.setText("类型:" + StringFormatUtil.formatGenres(subjectsBean.getGenres()));
        tvOneDay.setText("上映日期:" + subjectsBean.getYear());
        //电影详情的id
        id = subjectsBean.getId();
    }

}
项目:MVP-Practice-Project-Template    文件:StateActivity.java   
private void initHeadView() {
    int headLayoutId = bindHeadLayoutId();
    appBar = (AppBarLayout) findViewById(R.id.app_bar);
    ViewStub headViewStub = (ViewStub) findViewById(R.id.base_state_head);
    if (headLayoutId != 0 && headViewStub != null) {
        appBar.setVisibility(View.VISIBLE);
        headViewStub.setLayoutResource(headLayoutId);
        headViewStub.inflate();
    }
}
项目:FlexibleSearchBar    文件:MainActivity.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    float alpha = Math.abs((float) verticalOffset / appBarLayout.getTotalScrollRange());
    toolbar.setAlpha(alpha);
    if (alpha >= 1) {
        searchbarview.startOpen();
    } else {
        searchbarview.startClose();
    }
}
项目:Goalie_Android    文件:MainActivity.java   
@Override
public void onPageSelected(int position) {
    MyGoalsPresenter myGoalsPresenter = mViewPagerAdapter.getMyGoalsPresenter();
    if (myGoalsPresenter != null)
        myGoalsPresenter.closeFABMenu();
    AppBarLayout appBarLayout = findViewById(R.id.appbar);
    appBarLayout.setExpanded(true, true);
}
项目:GitHub    文件:RefreshContentWrapper.java   
protected void wrapperCoordinatorLayout(CoordinatorLayout layout, final RefreshLayout refreshLayout) {
    for (int i = layout.getChildCount() - 1; i >= 0; i--) {
        View view = layout.getChildAt(i);
        if (view instanceof AppBarLayout) {
            ((AppBarLayout) view).addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
                @Override
                public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                    mEnableRefresh = verticalOffset >= 0;
                    mEnableLoadmore = refreshLayout.isEnableLoadmore() && (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0;
                }
            });
        }
    }
}
项目:OpenEyesReading-android    文件:ArticleFragment.java   
@Override
    public void initView(View rootView) {
        ButterKnife.bind(this, rootView);
        mContentView.setVisibility(View.GONE);
        mNullView.setVisibility(View.VISIBLE);
//        initDatas(AppUtils.Constants.URL_ARTICLE);
        mAppbarParams = (AppBarLayout.LayoutParams) mAppbar.getChildAt(0).getLayoutParams();
        updateToolbarScroll(false);
    }
项目:School1-Android    文件:MainActivity.java   
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    drawerLayout.closeDrawer(GravityCompat.START);
    ((AppBarLayout) findViewById(R.id.activity_main_app_bar_layout)).setExpanded(true);

    int itemId = item.getItemId();

    // Use previous drawerItemId
    if (itemId == R.id.action_dashboard || itemId == R.id.action_ideas)
        configuration.edit().putInt("drawerItemId", itemId).apply();
    else if (itemId == R.id.action_share) {
        sendShareMessage();
        itemId = drawerItemId;
    }
    if (drawerItemId == itemId) {
        currentFragment = null;
        return true;
    }

    // Update drawerItemId
    drawerItemId = itemId;

    int position = getItemIndex(drawerItemId);
    if (getSupportActionBar() != null)
        getSupportActionBar().setTitle(navigationView.getMenu().findItem(fragmentIds[position]).getTitle());
    currentFragment = navigationFragments[position];

    if (currentFragment instanceof FloatingActionButtonHandler)
        ((FloatingActionButtonHandler) currentFragment).handleFloatingActionButton(floatingActionButton);
    else
        floatingActionButton.setVisibility(View.GONE);

    if (currentFragment instanceof TabLayoutHandler)
        ((TabLayoutHandler) currentFragment).handleTabLayout(tabLayout);
    else
        tabLayout.setVisibility(View.GONE);
    return true;
}
项目:SmartRefreshLayout    文件:RefreshContentWrapper.java   
protected void wrapperCoordinatorLayout(ViewGroup layout, final RefreshLayout refreshLayout) {
    for (int i = layout.getChildCount() - 1; i >= 0; i--) {
        View view = layout.getChildAt(i);
        if (view instanceof AppBarLayout) {
            ((AppBarLayout) view).addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
                @Override
                public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                    mEnableRefresh = verticalOffset >= 0;
                    mEnableLoadmore = refreshLayout.isEnableLoadmore() && (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0;
                }
            });
        }
    }
}
项目:BeautifulGirls    文件:BaseActivity.java   
/**
 * 如果存在Toolbar在子类中调用setToolbar方法
 *
 * @param isBack
 */
protected void setToolbar(boolean isBack) {
    mAppBar = (AppBarLayout) findViewById(R.id.appbar);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mAppBar == null || mToolbar == null) {
        throw new IllegalStateException("The subClass must contain a AppBarLayout and Toolbar");
    }
    mToolbar.setOnClickListener(view -> onToolbarClick());
    setSupportActionBar(mToolbar);
    if (isBack) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
项目:revolution-irc    文件:ThemedActivity.java   
@Override
public void setSupportActionBar(@Nullable Toolbar toolbar) {
    super.setSupportActionBar(toolbar);
    if (ThemeHelper.hasCustomPrimaryColor(this)) {
        toolbar.setBackgroundColor(ThemeHelper.getPrimaryColor(this));
        if (toolbar.getParent() instanceof AppBarLayout)
            ((View) toolbar.getParent()).setBackgroundColor(ThemeHelper.getPrimaryColor(this));
    }
}
项目:MVP-Practice-Project-Template    文件:DataListActivity.java   
private void initHeadView() {
    appBar = (AppBarLayout) findViewById(R.id.app_bar);
    int headLayoutId = bindHeadLayoutId();
    ViewStub headViewStub = (ViewStub) findViewById(R.id.base_state_head);
    if (headLayoutId != 0 && headViewStub != null) {
        appBar.setVisibility(View.VISIBLE);
        headViewStub.setLayoutResource(headLayoutId);
        headViewStub.inflate();
    }
}
项目:Android-skin-support    文件:CollapsingToolbarLayoutActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing_toolbar_layout);
    mIvPlaceholder = (ImageView) findViewById(R.id.main_iv_placeholder);
    mLlTitleContainer = (LinearLayout) findViewById(R.id.main_ll_title_container);
    mFlTitleContainer = (FrameLayout) findViewById(R.id.main_fl_title);
    mAblAppBar = (AppBarLayout) findViewById(R.id.main_abl_app_bar);
    mTvToolbarTitle = (TextView) findViewById(R.id.main_tv_toolbar_title);
    mTbToolbar = (Toolbar) findViewById(R.id.main_tb_toolbar);
    mTbToolbar.setTitle("");

    // AppBar的监听
    mAblAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int maxScroll = appBarLayout.getTotalScrollRange();
            float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll;
            handleAlphaOnTitle(percentage);
            handleToolbarTitleVisibility(percentage);
        }
    });

    findViewById(R.id.small_photo).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(CollapsingToolbarLayoutActivity.this, SettingsActivity.class));
        }
    });

    initParallaxValues(); // 自动滑动效果
}
项目:Farmacias    文件:FavoriteFragment.java   
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mAppBarLayout = (AppBarLayout) getActivity().findViewById(R.id.appBarLayout);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        float elevation =getActivity().getResources().getDimension(R.dimen.appbar_elevation);
        setAppBarElevation(elevation);
    }
}
项目:react-native-collapsing-toolbar    文件:AppBarLayoutManager.java   
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
    WritableMap event = Arguments.createMap();
    event.putDouble("offset", verticalOffset);
    ReactContext reactContext = (ReactContext) appBarLayout.getContext();
    reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(appBarLayout.getId(), "topOffsetChanged", event);
}
项目:revolution-irc    文件:SetupBigHeaderActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (mCustomContentViewId != 0)
        setContentView(mCustomContentViewId);
    else
        setContentView(R.layout.activity_setup_big_header);

    AppBarLayout appBar = findViewById(R.id.appbar);

    CollapsingToolbarLayout toolbarLayout = findViewById(R.id.toolbar_layout);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mLayout = findViewById(R.id.layout);
    mLayout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
        int height = mLayout.getHeight();
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)
                appBar.getLayoutParams();
        params.height = height / 3;
        appBar.setLayoutParams(params);

        int childHeight = (mContentView != null ? mContentView.getHeight() : 0);
        if (mContentView instanceof NestedScrollView)
            childHeight = ((NestedScrollView) mContentView).getChildAt(0).getHeight();
        boolean needsScroll = (mContentView != null && childHeight > height - params.height);

        AppBarLayout.LayoutParams paramsToolbar = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
        paramsToolbar.setScrollFlags(needsScroll
                ? (AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED)
                : 0);
        toolbarLayout.setLayoutParams(paramsToolbar);
    });
}