Java Code Examples for android.support.design.widget.CollapsingToolbarLayout#setExpandedTitleColor()

The following examples show how to use android.support.design.widget.CollapsingToolbarLayout#setExpandedTitleColor() . 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: 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 2
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 3
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 4
Source File: BaseDetailDelegate.java    From CoreModule with Apache License 2.0 5 votes vote down vote up
@Override
public Toolbar getToolbar() {
    super.getToolbar();
    Toolbar toolbar = get(R.id.toolbar);
    CollapsingToolbarLayout collapsingToolbar = get(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(rootView.getResources().getString(R.string.blog_detail));
    int titleColor = rootView.getResources().getColor(android.R.color.white);
    collapsingToolbar.setCollapsedTitleTextColor(titleColor);
    collapsingToolbar.setExpandedTitleColor(titleColor);
    return toolbar;
}
 
Example 5
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 6
Source File: GroupDetailActivity.java    From citrus with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_detail);
    ButterKnife.bind(this);
    Toolbar toolbar = findById(this, R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    setupFloatingActionButton();

    Intent intent = getIntent();
    mGroupName = intent.getStringExtra(KEY_GROUP_NAME);

    CollapsingToolbarLayout collapsingToolbar = findById(this, R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(mGroupName);
    collapsingToolbar.setCollapsedTitleTextColor(getResources().getColor(android.R.color.white));
    collapsingToolbar.setExpandedTitleColor(getResources().getColor(android.R.color.white));

    ImageView headerImageView = findById(this, R.id.backdrop);
    GroupHelper.setupDefaultGroupImage(mGroupName, headerImageView);

    mListsFragment = ListsFragment.newInstance(mGroupName);
    FragmentManager manager = getSupportFragmentManager();
    manager.beginTransaction()
            .replace(R.id.group_detail_container, mListsFragment)
            .commit();
}
 
Example 7
Source File: CollapsingToolbarActivity.java    From twoh-android-material-design with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    setContentView(R.layout.activity_collapse_toolbar);

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

    // pengaturan dan inisialisasi collapsing toolbar
    collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("TWOH's Engineering");
    collapsingToolbar.setExpandedTitleColor(Color.parseColor("#44ffffff"));

    // inisialisasi ImageView
    ImageView header = (ImageView) findViewById(R.id.iv_header);

    // mengambil gambar bitmap yang digunakan pada image view
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
            R.drawable.sheryl);

    // mengekstrak warna dari gambar yang digunakan
    Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            mutedColor = palette.getMutedColor(R.attr.colorPrimary);
            collapsingToolbar.setContentScrimColor(mutedColor);
        }
    });
    super.onCreate(savedInstanceState);
    FloatingActionButton btTutorial = (FloatingActionButton) findViewById(R.id.fab);
    btTutorial.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            decideToDisplay();
            readTheTutorial(Const.TUTORIAL_COLLAPSINGTOOLBAR);
        }
    });
}
 
Example 8
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 9
Source File: VideoPlayActivity.java    From meiShi with Apache License 2.0 5 votes vote down vote up
private void initView() {
    toolbar= (Toolbar) findViewById(R.id.tool_bar);
    setUpCommonBackTooblBar(R.id.tool_bar, "视频播放");
    appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
    appBarLayout.addOnOffsetChangedListener(this);
    CollapsingToolbarLayout collapsing_toolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    ViewCompat.requestApplyInsets(collapsing_toolbar);
    collapsing_toolbar.setTitleEnabled(false);
    collapsing_toolbar.setExpandedTitleColor(Color.TRANSPARENT);
    resetCollapsingToolbarLayout(collapsing_toolbar);
    mVideoPlayHeader = new VideoPlayHeader(this, findViewById(R.id.video_header));
    initRecyclerView();
}
 
Example 10
Source File: Talk.java    From mConference-Framework with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_talk);

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

    final TalkDetails talkDetails = (TalkDetails)getIntent().getSerializableExtra("TalkDetails");
    final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    upArrow.setColorFilter(ContextCompat.getColor(this, android.R.color.white), PorterDuff.Mode.SRC_ATOP);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(upArrow);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.talk_toolbar_layout);
    collapsingToolbarLayout.setTitle(talkDetails.getName());
    collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(this, android.R.color.white));
    collapsingToolbarLayout.setCollapsedTitleTextColor(ContextCompat.getColor(this, android.R.color.white));

    final ImageView talkImage = (ImageView) findViewById(R.id.talk_collapsible_image);
    TextView talkTime = (TextView) findViewById(R.id.talk_time_detail);
    TextView talkLocation = (TextView) findViewById(R.id.talk_venue_detail);
    TextView talkDesc = (TextView) findViewById(R.id.talk_desc_detail);

    SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm a");
    String talkTimeText = dateFormat.format(talkDetails.getStartTime())
            + " - " + dateFormat.format(talkDetails.getEndTime());
    talkTime.setText(talkTimeText);

    talkLocation.setText(talkDetails.getLocation());
    talkDesc.setText(talkDetails.getDesc());

    Picasso.with(this)
            .load(Uri.parse(talkDetails.getImageURL()))
            .error(R.drawable.placeholder_1)
            .fit().centerCrop().into(talkImage, new com.squareup.picasso.Callback() {
        @Override
        public void onSuccess() {
            applyPalette(talkImage);
        }

        @Override
        public void onError() {
            Log.d("Talk.java", "Error caused by Picasso");
            applyPalette(talkImage);
        }
    });

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.talk_reminder);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_EDIT);
            intent.setType("vnd.android.cursor.item/event");
            intent.putExtra(CalendarContract.Events.TITLE,
                    talkDetails.getName());
            intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
                    talkDetails.getStartTime().getTime());
            intent.putExtra(CalendarContract.Events.EVENT_LOCATION,
                    talkDetails.getLocation());
            intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
                    talkDetails.getEndTime().getTime());
            intent.putExtra(CalendarContract.Events.ALL_DAY, false);
            intent.putExtra(CalendarContract.Events.DESCRIPTION,
                    talkDetails.getShortDesc());
            v.getContext().startActivity(intent);
        }
    });
}
 
Example 11
Source File: SupportAdapters.java    From AndroidSchool with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("app:expandedTitleColor")
public static void setExpandedTitleColor(@NonNull CollapsingToolbarLayout layout,
                                         @ColorRes int colorRes) {
    layout.setExpandedTitleColor(ContextCompat.getColor(layout.getContext(), colorRes));
}