android.support.design.widget.CollapsingToolbarLayout Java Examples

The following examples show how to use android.support.design.widget.CollapsingToolbarLayout. 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: 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 #2
Source File: NoteinfoActivity.java    From Memory-capsule with Apache License 2.0 6 votes vote down vote up
private void initToolbarSeting(){//toolbard的设置
    toolbar=(Toolbar)this.findViewById(R.id.toolbar_noteinfo);
    coordinatorLayout_noteinfo=(CoordinatorLayout)this.findViewById(R.id.coordinator_noteinfo);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    CollapsingToolbarLayout collapsingToolbarLayout=(CollapsingToolbarLayout)findViewById(R.id.cool_noteinfo);
    collapsingToolbarLayout.setExpandedTitleColor(Color.WHITE);
    collapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
}
 
Example #3
Source File: SGToolsDetailFragment.java    From SteamGifts with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    layout = inflater.inflate(R.layout.fragment_sgtools, container, false);

    appBarLayout = (CollapsingToolbarLayout) getActivity().findViewById(R.id.toolbar_layout);
    appBarLayout.setTitle("Loading SGTools...");

    if (giveaway != null) {
        onGiveawayLoaded(giveaway);
    } else {
        task = new LoadGiveawayTask(this, uuid);
        task.execute();
    }

    return layout;
}
 
Example #4
Source File: MainActivity.java    From android-apps with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.MyToolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar);
    collapsingToolbar.setTitle("My Toolbar Tittle");

    collapsingToolbar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorAccent));
    collapsingToolbar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
}
 
Example #5
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 #6
Source File: UserInfoActivity.java    From meiShi with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    setContentView(R.layout.activity_user_info);
    setStateBarColor(R.color.colorPrimaryDark);
    mUserEntity = App.getInstance().getOauthUserEntity().getUser();
    video = mUserEntity.getVideos_count() + "\n" + getString(R.string.video);
    reposts = mUserEntity.getReposts_count() + "\n" + getString(R.string.reposts);
    following = mUserEntity.getFriends_count() + "\n" + getString(R.string.following);
    followers = mUserEntity.getFollowers_count() + "\n" + getString(R.string.following);
    mUserInfoHeader = new UserInfoHeader(this, findView(R.id.layout_header_view));
    mUserInfoHeader.bindData(mUserEntity);
    setUpCommonBackTooblBar(R.id.toolbar, " ");
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(getString(R.string.title_home));
    collapsingToolbar.setExpandedTitleColor(Color.TRANSPARENT);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(mViewPager);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.addTab(tabLayout.newTab().setText(video));
    tabLayout.addTab(tabLayout.newTab().setText(reposts));
    tabLayout.addTab(tabLayout.newTab().setText(followers));
    tabLayout.addTab(tabLayout.newTab().setText(following));
    tabLayout.setupWithViewPager(mViewPager);
}
 
Example #7
Source File: Activity_QRcodeResult.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    foods_imageView = (ImageView) findViewById(R.id.foods_image_view);
    foods_ingredients_text = (TextView) findViewById(R.id.foods_ingredients_text);
    foods_description_text = (TextView) findViewById(R.id.foods_description_text);
    fab_comment = (FloatingActionButton) findViewById(R.id.fab_comment);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    collapsingToolbar.setTitle(name);

    Glide.with(this).load(imageUrl).into(foods_imageView);
    foods_ingredients_text.setText("配料:" + ingredients);
    foods_description_text.setText("简介:" + description);
    ratingBar.setProgress(rating);
}
 
Example #8
Source File: MainFragment.java    From YuanNewsForAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) view.findViewById(R.id.collapsing);
    collapsingToolbar.setTitle("失控");
    //设置ViewPager
    mViewPager = (ViewPager) view.findViewById(R.id.viewPager);
    mViewPager.setAdapter(mainViewPagerAdapter);

    //给TabLayout增加Tab, 并关联ViewPager
    tabLayout= (TabLayout) view.findViewById(R.id.sliding_tabs);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setupWithViewPager(mViewPager);
    //加载数据
    mainPresenter.loadDataRequest();
}
 
Example #9
Source File: MobelBrowserActivity.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String url = intent.getStringExtra(KEY_BLOG_URL);
    String title = intent.getStringExtra(KEY_BLOG_TITLE);
    CollapsingToolbarLayout collapsingToolbar = viewDelegate.get(R.id.collapsing_toolbar);
    title = linkDispatcher.getActionTitle(url, title);
    if (title != null) {
        collapsingToolbar.setTitle(title);
    } else {
        collapsingToolbar.setTitle(getString(R.string.app_name));
    }

    viewDelegate.setContentUrl(url);
}
 
Example #10
Source File: BlogDetailActivity.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    url = intent.getStringExtra(KEY_BLOG_URL);
    String title = intent.getStringExtra(KEY_BLOG_TITLE);
    CollapsingToolbarLayout collapsingToolbar = viewDelegate.get(R.id.collapsing_toolbar);
    if (title != null) {
        collapsingToolbar.setTitle(title);
    } else {
        collapsingToolbar.setTitle(getString(R.string.kymjs_blog_name));
    }

    readCache();
    doRequest();
}
 
Example #11
Source File: ScrimHelper.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
public ScrimHelper(AppBarLayout appBarLayout, CollapsingToolbarLayout toolbarLayout) {
    appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
        if (scrimListener == null) return;
        if (appBarLayout1.getHeight() + verticalOffset <= toolbarLayout.getScrimVisibleHeightTrigger()) {
            if (!scrim) {
                scrim = true;
                scrimListener.onScrimChanged(true);
            }
        } else {
            if (scrim) {
                scrim = false;
                scrimListener.onScrimChanged(false);
            }
        }
    });
}
 
Example #12
Source File: BlogDetailDelegate.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
private Transformation getTransformation(final String t) {
    return new Transformation() {
        @Override
        public Bitmap transform(Bitmap b) {
            Palette.from(b).generate(new Palette.PaletteAsyncListener() {
                @Override
                public void onGenerated(final Palette palette) {
                    int defaultColor = rootView.getResources().getColor
                            (android.R.color.white);
                    int titleColor = palette.getLightVibrantColor
                            (defaultColor);
                    CollapsingToolbarLayout collapsingToolbar = get(R.id
                            .collapsing_toolbar);
                    collapsingToolbar.setExpandedTitleColor(titleColor);
                }
            });
            return b;
        }

        @Override
        public String key() {
            return t;
        }
    };
}
 
Example #13
Source File: ItemDetailFragment.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments().containsKey(ARG_ITEM_ID)) {
        // Load the dummy content specified by the fragment
        // arguments. In a real-world scenario, use a Loader
        // to load content from a content provider.
        mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));

        Activity activity = this.getActivity();
        CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
        if (appBarLayout != null) {
            appBarLayout.setTitle(mItem.content);
        }
    }
}
 
Example #14
Source File: PlaylistActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playlist);
    loadBingPic();
    playListInfo = getIntent().getParcelableExtra("playlistInfo");
    toolbar = (Toolbar) findViewById(R.id.activity_playlist_toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    CollapsingToolbarLayout mCollapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsingToolbarLayout);
    mCollapsingToolbarLayout.setTitle(playListInfo.getName());
    dbManager = DBManager.getInstance(this);
    musicInfoList = dbManager.getMusicListByPlaylist(playListInfo.getId());
    initView();
    register();
}
 
Example #15
Source File: StatusBarCompatKitKat.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.addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
    View mContentChild = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
    mContentChild.setFitsSystemWindows(false);
    ((View) appBarLayout.getParent()).setFitsSystemWindows(false);
    appBarLayout.setFitsSystemWindows(false);
    collapsingToolbarLayout.setFitsSystemWindows(false);
    collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(false);
    toolbar.setFitsSystemWindows(true);
    if (toolbar.getTag() == null) {
        CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
        lp.height += getStatusBarHeight(activity);
        toolbar.setLayoutParams(lp);
        toolbar.setTag(Boolean.valueOf(true));
    }
    int statusBarHeight = getStatusBarHeight(activity);
    removeFakeStatusBarViewIfExist(activity);
    removeMarginTopOfContentChild(mContentChild, statusBarHeight);
}
 
Example #16
Source File: PlaylistActivity.java    From MeetMusic with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playlist);
    loadBingPic();
    playListInfo = getIntent().getParcelableExtra("playlistInfo");
    toolbar = (Toolbar) findViewById(R.id.activity_playlist_toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    CollapsingToolbarLayout mCollapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsingToolbarLayout);
    mCollapsingToolbarLayout.setTitle(playListInfo.getName());
    dbManager = DBManager.getInstance(this);
    musicInfoList = dbManager.getMusicListByPlaylist(playListInfo.getId());
    initView();
    register();
}
 
Example #17
Source File: CollapsingToolbarLayoutSetter.java    From MeiZiNews with MIT License 5 votes vote down vote up
@Override
public void setValue(Resources.Theme newTheme, int themeId) {
    if (mView == null) {
        return;
    }

    ((CollapsingToolbarLayout) mView).setStatusBarScrimColor(getColor(newTheme));
    ((CollapsingToolbarLayout) mView).setContentScrimColor(getColor(newTheme));
    ((CollapsingToolbarLayout) mView).setBackgroundColor(getColor(newTheme));
}
 
Example #18
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 #19
Source File: BannerDetailActivity.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
    TranslucentUtils.setColor(this, getResources().getColor(R.color.colorPrimary), 1);
    // id = getIntent().getStringExtra("id");
    // userid = getIntent().getStringExtra("userid");

    mResultsBean = (HomeBannerBean.ResultsBean) getIntent().getSerializableExtra("result");

    if (mResultsBean != null) {
        url = mResultsBean.getUrl();
        title = mResultsBean.getTitle();
        subtitle = mResultsBean.getSubtitle();
    }
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle(getResources().getString(R.string.news_detail));
    mTvTitle = (TextView) findViewById(R.id.tv_title);
    mTvCategory = (TextView) findViewById(R.id.tv_category);
    // mTvViewCount = (TextView) findViewById(R.id.tv_view_count);
    mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    mWebView = (WebView) findViewById(R.id.web_view);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    mImgBg = (ImageView) findViewById(R.id.img_bg);
    setSupportActionBar(mToolbar);

    //        设置返回箭头
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example #20
Source File: ParallaxImageToolbarActivity.java    From CoordinatorLayoutSample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parallax_image_toolbar);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String toolbarTitle = getResources().getString(R.string.sample_parallax_image_tollbar);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(toolbarTitle);
}
 
Example #21
Source File: EnterInfoActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_basicinfo);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, new BasicInfoFragment())
                .commit();
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Information");
}
 
Example #22
Source File: DetailActivity.java    From MaterializeYourApp with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initActivityTransitions();
    setContentView(R.layout.activity_detail);

    ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE);
    supportPostponeEnterTransition();

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String itemTitle = getIntent().getStringExtra(EXTRA_TITLE);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitle(itemTitle);
    collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));

    final ImageView image = (ImageView) findViewById(R.id.image);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(image, new Callback() {
        @Override public void onSuccess() {
            Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
            Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
                public void onGenerated(Palette palette) {
                    applyPalette(palette);
                }
            });
        }

        @Override public void onError() {

        }
    });

    TextView title = (TextView) findViewById(R.id.title);
    title.setText(itemTitle);
}
 
Example #23
Source File: ContactDetailActivity.java    From Rumble with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_contact_detail);

    Bundle args = getIntent().getExtras();
    String contactName = args.getString("ContactName");
    String contactUID  = args.getString("ContactID");

    /* set the toolbar */
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(contactName);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(contactName);

    /* set the background header */
    ImageView header = (ImageView) findViewById(R.id.header_background);
    ColorGenerator generator = ColorGenerator.DEFAULT;
    header.setBackgroundDrawable(
            builder.build(contactName.substring(0, 1),
            generator.getColor(contactUID)));

    /* setting up the view pager and the tablayout */
    TabLayout tabLayout = (TabLayout) findViewById(R.id.contact_tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.contact_viewpager);
    ContactDetailPagerAdapter pagerAdapter = new ContactDetailPagerAdapter(getSupportFragmentManager(), args);
    viewPager.setAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setSelectedTabIndicatorHeight(10);
}
 
Example #24
Source File: NestedScroll.java    From px-android with MIT License 5 votes vote down vote up
@Nullable
private static CollapsingToolbarLayout findCollapsingToolbarLayoutChildIn(final ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        final View child = viewGroup.getChildAt(i);
        if (child instanceof CollapsingToolbarLayout) {
            return (CollapsingToolbarLayout) child;
        } else if (child instanceof ViewGroup) {
            return findCollapsingToolbarLayoutChildIn((ViewGroup) child);
        }
    }
    return null;
}
 
Example #25
Source File: CustomMatchers.java    From Villains-and-Heroes with Apache License 2.0 5 votes vote down vote up
public static Matcher<View> withToolbarLayoutTitle(final Matcher<String> textMatcher) {
    return new BoundedMatcher<View, CollapsingToolbarLayout>(CollapsingToolbarLayout.class) {
        @Override
        public void describeTo(Description description) {
            description.appendText("with toolbar layout title: ");
            textMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(CollapsingToolbarLayout toolbarLayout) {
            //noinspection ConstantConditions
            return textMatcher.matches(toolbarLayout.getTitle());
        }
    };
}
 
Example #26
Source File: MovieDetailFragment.java    From Movies-Android-Kata with Apache License 2.0 5 votes vote down vote up
@Override
public void renderTitle(String name) {
    //setTitle from background working in phone
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) getActivity().findViewById(R.id.toolbar_layout);
    collapsingToolbar.setTitle(name);

    //setTitle from background working in tablet
    getActivity().setTitle(name);
}
 
Example #27
Source File: NewsDetailView.java    From AndroidModulePattern with Apache License 2.0 5 votes vote down vote up
private void initView() {
    inflate(getContext(), R.layout.view_news_detail, this);
    mToolbarImage = (ImageView) findViewById(R.id.toolbar_image);
    mToolbarText = (TextView) findViewById(R.id.toolbar_text);
    mCollapsingLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_layout);
    mDetailText = (TextView) findViewById(R.id.news_detail_text);

    isActive = true;
}
 
Example #28
Source File: InnerQuestionActivity.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void themePatch() {
    super.themePatch();
    $(R.id.just_bg_primary).setBackgroundColor(ThemeController.getCurrentColor().mainColor);
    $(R.id.collapseToolBar).setBackgroundColor(ThemeController.getCurrentColor().mainColor);
    ((CollapsingToolbarLayout)$(R.id.collapseToolBar)).setContentScrimColor((ThemeController.getCurrentColor().mainColor));
}
 
Example #29
Source File: ComicDetailFragment.java    From DaggerWorkshopGDG with Apache License 2.0 5 votes vote down vote up
public void setComicInfo(ComicModel comicModel) {
    if (comicModel != null) {
        String title = comicModel.getTitle();
        if (Strings.isNullOrEmpty(title)) {
            title = getString(R.string.error_no_title);
        }
        comicTitle.setText(title);

        String description = comicModel.getDescription();
        if (Strings.isNullOrEmpty(description)) {
            description = getString(R.string.error_no_description);
        }
        comicDescription.setText(Html.fromHtml(description));

        Activity activity = this.getActivity();

        if (activity != null) {
            ImageView comicImage = (ImageView) activity.findViewById(R.id.comic_image);
            Picasso.with(activity).load(comicDetailPresenter.getRandomImageUrl(comicModel)).error(R.drawable.default_comic)
                    .fit().centerCrop().into(comicImage);

            CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
            if (appBarLayout != null) {
                appBarLayout.setTitle(title);
                appBarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));
            }
        }
    } else {
        comicTitle.setText(getString(R.string.error_no_title));
        comicDescription.setText(getString(R.string.error_comic));
    }
}
 
Example #30
Source File: SkinMaterialCollapsingToolbarLayout.java    From Android-skin-support with MIT License 5 votes vote down vote up
public SkinMaterialCollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.CollapsingToolbarLayout, defStyleAttr,
            R.style.Widget_Design_CollapsingToolbar);
    mContentScrimResId = a.getResourceId(R.styleable.CollapsingToolbarLayout_contentScrim, INVALID_ID);
    mStatusBarScrimResId = a.getResourceId(R.styleable.CollapsingToolbarLayout_statusBarScrim, INVALID_ID);
    a.recycle();
    applyContentScrimResource();
    applyStatusBarScrimResource();
    mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, 0);
}