Java Code Examples for com.google.android.material.appbar.CollapsingToolbarLayout#setTitle()

The following examples show how to use com.google.android.material.appbar.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: ScrollingActivity.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    detailPlayer = (LandLayoutVideo) findViewById(R.id.detail_player);
    root = (CoordinatorLayout) findViewById(R.id.root_layout);

    setSupportActionBar(toolbar);
    toolBarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    toolBarLayout.setTitle(getTitle());

    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            detailPlayer.startPlayLogic();
            root.removeView(fab);
        }
    });

    appBar = (AppBarLayout) findViewById(R.id.app_bar);
    appBar.addOnOffsetChangedListener(appBarStateChangeListener);
}
 
Example 2
Source File: TestUtilsActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets title on the {@link CollapsingToolbarLayout}. */
public static ViewAction setTitle(final CharSequence title) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(CollapsingToolbarLayout.class);
    }

    @Override
    public String getDescription() {
      return "set toolbar title";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) view;
      collapsingToolbarLayout.setTitle(title);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example 3
Source File: AboutActivity.java    From PocketMaps with MIT License 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        CollapsingToolbarLayout toolBarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
        toolBarLayout.setTitle(getTitle());

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View view) {
                //                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction
                // ("Action", null)
                //                        .show();

                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://github.com/junjunguo/PocketMaps/")));

            }
        });

        //         set status bar
//        new SetStatusBarColor().setSystemBarColor(findViewById(R.id.statusBarBackgroundSettings),
//                getResources().getColor(R.color.my_primary_dark), this);
    }
 
Example 4
Source File: MainActivity.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar =  findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitle(getResources().getString(R.string.app_name));


    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    dynamicToolbarColor();

    toolbarTextAppernce();
}
 
Example 5
Source File: EventActivity.java    From haven with GNU General Public License v3.0 5 votes vote down vote up
/**
 * On event fetched update {@link #mEvent} and set Activity title
 */
private void onEventFetched(@NonNull Event event) {
    mEvent = event;
    String title = mEvent.getStartTime().toLocaleString();
    setTitle(title);
    CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.toolbar_layout);
    collapsingToolbarLayout.setTitle(title);

    //((TextView)findViewById(R.id.toolbar_title)).setText(mEvent.getStartTime().toLocaleString());
}
 
Example 6
Source File: OdysseyMainActivity.java    From odyssey with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setupToolbar(String title, boolean scrollingEnabled, boolean drawerIndicatorEnabled, boolean showImage) {
    // set drawer state
    mDrawerToggle.setDrawerIndicatorEnabled(drawerIndicatorEnabled);

    ImageView collapsingImage = findViewById(R.id.collapsing_image);
    View collapsingImageGradientTop = findViewById(R.id.collapsing_image_gradient_top);
    View collapsingImageGradientBottom = findViewById(R.id.collapsing_image_gradient_bottom);
    if (collapsingImage != null && collapsingImageGradientTop != null && collapsingImageGradientBottom != null) {
        if (showImage) {
            collapsingImage.setVisibility(View.VISIBLE);
            collapsingImageGradientTop.setVisibility(View.VISIBLE);
            collapsingImageGradientBottom.setVisibility(View.VISIBLE);
        } else {
            collapsingImage.setVisibility(View.GONE);
            collapsingImage.setImageDrawable(null);
            collapsingImageGradientTop.setVisibility(View.GONE);
            collapsingImageGradientBottom.setVisibility(View.GONE);
        }
    }
    // set scrolling behaviour
    CollapsingToolbarLayout toolbar = findViewById(R.id.collapsing_toolbar);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    params.height = -1;

    if (scrollingEnabled && !showImage) {
        toolbar.setTitleEnabled(false);
        setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    } else if (!scrollingEnabled && showImage && collapsingImage != null) {
        toolbar.setTitleEnabled(true);
        toolbar.setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED + AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
    } else {
        toolbar.setTitleEnabled(false);
        setTitle(title);
        params.setScrollFlags(0);
    }
}