示例#1
0
  @Override
  public void onDetach() {
    super.onDetach();

    android.support.v7.widget.Toolbar toolbar =
        (android.support.v7.widget.Toolbar) getActivity().findViewById(R.id.toolbar);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();

    // Ripristina gli scrollFlags originali
    params.setScrollFlags(scrollFlags);

    hideSoftKeyboard();

    /*
    //SE SI VUOLE MOSTRARE IL TABLAYOUT

    TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs);
    tabLayout.setVisibility(View.GONE);


    // SE SI VUOLE MODIFICARE IL app:layout_behavior del FrameLayout

    if(behavior == null)
        return;

    FrameLayout layout =(FrameLayout) getActivity().findViewById(R.id.dashboard_content);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) layout.getLayoutParams();

    params.setBehavior(behavior);

    layout.setLayoutParams(params);

    behavior = null;
    */
  }
  private void addToolbarToLayout() {
    final AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);

    final AppBarLayout.LayoutParams toolbarParams =
        new AppBarLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, Util.getActionBarHeight(this));
    toolbarParams.setScrollFlags(
        AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
            | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);

    appBarLayout.addView(mToolbar, toolbarParams);

    setSupportActionBar(mToolbar);
  }
示例#3
0
  protected void myOnAttach(Context context) {

    android.support.v7.widget.Toolbar toolbar =
        (android.support.v7.widget.Toolbar) getActivity().findViewById(R.id.toolbar);

    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();

    // Salvo gli scrollFlags originali per poterli ripristinare nell'onDetach
    scrollFlags = params.getScrollFlags();

    params.setScrollFlags(0);

    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("Search students");

    /*
    //SE SI VUOLE MOSTRARE IL TABLAYOUT

    TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs);
    tabLayout.setVisibility(View.VISIBLE);


    // SE SI VUOLE MODIFICARE IL app:layout_behavior del FrameLayout


    if(behavior != null)
        return;

    FrameLayout layout =(FrameLayout) getActivity().findViewById(R.id.frame);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) layout.getLayoutParams();

    behavior = params.getBehavior();
    params.setBehavior(null);
    */

    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });
    fab.setVisibility(View.GONE);
  }