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

The following examples show how to use android.support.design.widget.CollapsingToolbarLayout#setTitle() . 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: 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 2
Source File: CheeseDetailActivity.java    From cheesesquare with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    Intent intent = getIntent();
    final String cheeseName = intent.getStringExtra(EXTRA_NAME);

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

    CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(cheeseName);

    loadBackdrop();
}
 
Example 3
Source File: ItemDetailFragment.java    From shrinker 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 4
Source File: CheeseDetailActivity.java    From streamsupport with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    Intent intent = getIntent();
    final String cheeseName = intent.getStringExtra(EXTRA_NAME);

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

    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(cheeseName);

    loadBackdrop();
}
 
Example 5
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 6
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 7
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 8
Source File: AlbumActivity.java    From BeMusic with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);

    mAlbum = (Album)getIntent().getSerializableExtra("album");

    mColTbLayout = (CollapsingToolbarLayout)findViewById(R.id.album_col_toolbar_layout);
    mTb = (Toolbar)findViewById(R.id.album_toolbar);
    mThumbIv = (ImageView)findViewById(R.id.album_thumb);
    mRv = (RecyclerView)findViewById(R.id.album_rv);
    mFab = (FloatingActionButton)findViewById(R.id.album_start);

    mRv.setLayoutManager(new LinearLayoutManager(this));

    mAdapter = new DelegateAdapter(this);
    mRv.setAdapter(mAdapter);

    mFab.setOnClickListener(mClickListener);

    setSupportActionBar(mTb);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mColTbLayout.setTitle(mAlbum.getAlbum());
    Glide.with(this).load(mAlbum.getAlbumArt()).into(mThumbIv);

    List<Song> songList = PlayManager.getInstance(this).getAlbumSongList(mAlbum.getId());
    if (songList != null) {
        mAdapter.addAll(songList, new DelegateParser<Song>() {
            @Override
            public LayoutImpl parse(DelegateAdapter adapter, Song data) {
                return new SongDelegate(data);
            }
        });
        mAdapter.notifyDataSetChanged();
    }
}
 
Example 9
Source File: RecentTracksFragment.java    From QuickLyric with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MainActivity mainActivity = (MainActivity) this.getActivity();
    ActionBar actionBar = (mainActivity).getSupportActionBar();
    CollapsingToolbarLayout toolbarLayout =
            mainActivity.findViewById(R.id.toolbar_layout);
    if (mainActivity.focusOnFragment) // focus is on Fragment
    {
        if (actionBar.getTitle() == null || !actionBar.getTitle().equals(this.getString(R.string.recent_tracks_title)))
            toolbarLayout.setTitle(getString(R.string.recent_tracks_title));
        inflater.inflate(R.menu.recent_tracks, menu);
    } else
        menu.clear();
}
 
Example 10
Source File: NewsDetileActivity.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
@Override
protected void initViews() {
    super.initViews();
    mGetIntent=getIntent();
    if(hasTitleImage()) {

        mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout);
        mCollapsingToolbarLayout.setTitle(mGetIntent.getStringExtra(TITLE));
        mTitleImage = (ImageView)findViewById(R.id.titleImage);
        mTitleImage.post(new Runnable() {
            @Override
            public void run() {
                Glide.with(NewsDetileActivity.this).load(mGetIntent.getStringExtra(IMAGE_URL))
                .placeholder(R.color.colorPrimary)
                .into(mTitleImage);
            }
        });

    } else {
        mToolBar.setBackgroundResource(R.color.colorPrimary);

    }
    mWebView = new WebView(getApplicationContext());
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setBackgroundColor(0);
    mWebLayout.addView(mWebView);

    getNewsDetail();
}
 
Example 11
Source File: CollapseLargeToolbarActivity.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_collapse_large_toolbar);

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

    String toolbarTitle = getResources().getString(R.string.sample_collapse_toolbar);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(toolbarTitle);
}
 
Example 12
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 13
Source File: CollapsingToolbarActivity.java    From android-coordinator-layout with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("哆啦A梦");
    RecyclerView mRecyclerView= (RecyclerView) findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setAdapter(new RecyclerViewAdapter(CollapsingToolbarActivity.this));
}
 
Example 14
Source File: ReviewAndConfirmActivity.java    From px-android with MIT License 5 votes vote down vote up
private void initToolbar() {
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar supportActionBar = getSupportActionBar();
    supportActionBar.setDisplayShowTitleEnabled(false);
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    supportActionBar.setDisplayShowHomeEnabled(true);
    toolbar.setNavigationOnClickListener(v -> onBackPressed());
    final CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitle(getString(R.string.px_activity_checkout_title));
    FontHelper.setFont(collapsingToolbarLayout, PxFont.REGULAR);
}
 
Example 15
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 16
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 17
Source File: CustomerDetails.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.customer_detail);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.customer_collapsing_toolbar);

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

    userImage = (ImageView) findViewById(R.id.user_image);
    findViewById(R.id.captureImage).setOnClickListener(this);

    fileManager = new OFileManager(this);
    if (toolbar != null)
        collapsingToolbarLayout.setTitle("");
    if (savedInstanceState != null) {
        mEditMode = savedInstanceState.getBoolean(KEY_MODE);
        newImage = savedInstanceState.getString(KEY_NEW_IMAGE);
    }
    app = (App) getApplicationContext();
    resPartner = new ResPartner(this, null);
    extras = getIntent().getExtras();
    if (hasRecordInExtra())
        partnerType = Customers.Type.valueOf(extras.getString(KEY_PARTNER_TYPE));
    if (!hasRecordInExtra())
        mEditMode = true;
    setupToolbar();
}
 
Example 18
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 19
Source File: ScrollCollapseLargeToolbarActivity.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_scroll_collapse_large_toolbar);

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

    String toolbarTitle = getResources().getString(R.string.sample_collapse_scroll_toolbar);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(toolbarTitle);

    mFab = findViewById(R.id.fab);

    NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scrollview);
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY > oldScrollY) {
                animateFab(false);
            } else {
                animateFab(true);
            }
        }
    });
}
 
Example 20
Source File: CollapsingToolbarLayout2Activity.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
private void initView() {
    mContentRV = (RecyclerView) findViewById(R.id.rv_content);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.ctl_title);
    collapsingToolbar.setTitle("DIY-Title");
}