title: android add two toolbars in the same activity ?
body: <p>I have a bottom menu as a toolbar and I need to add another one at the top as an actionbar. here is the code ofthe activity </p>
  
  <pre><code>public class ListViewPharms extends AppCompatActivity {
  public Toolbar mToolbar;
  ListView mListView;
  SimpleAdapter pharmAdapter;
  LinearLayout searchsec;
  // Search EditText
  EditText inputSearch;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
  
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_action_bar);
  
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_list_view_pharms_title);
  
  
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.mytoolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowTitleEnabled(false);
      setupEvenlyDistributedToolbar();
  
  
  
      inputSearch = (EditText) findViewById(R.id.search_bar);
  
      inputSearch.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
              // When user changed the Text
              ListViewPharms.this.pharmAdapter.getFilter().filter(cs);
          }
  
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                                        int arg3) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable arg0) {
              // TODO Auto-generated method stub
          }
      });
  
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
  
  
      MenuInflater inflater = getMenuInflater();
  
      inflater.inflate(R.menu.menu_register, menu);
  
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
          case R.id.action_home:
              Intent intent = new Intent(this, ListViewPharms.class);
              startActivity(intent);
              break;
          case R.id.action_cont:
              item.setIcon(getResources().getDrawable(R.drawable.icon2_active));
  
              Intent intent2 = new Intent(this, Contribute.class);
              startActivity(intent2);
              break;
          case R.id.action_info:
              Intent intent3 = new Intent(this, info.class);
              startActivity(intent3);
              break;
          case R.id.action_settings:
              Intent intent4 = new Intent(this, contactInfo.class);
              startActivity(intent4);
              break;
      }
      return true;
  }
  
  
  /**
   * This method will take however many items you have in your
   * menu/menu_main.xml and distribute them across your devices screen
   * evenly using a Toolbar. Enjoy!!
   */
  public void setupEvenlyDistributedToolbar(){
      // Use Display metrics to get Screen Dimensions
      Display display = getWindowManager().getDefaultDisplay();
      DisplayMetrics metrics = new DisplayMetrics();
      display.getMetrics(metrics);
  
      // Toolbar
      mToolbar = (Toolbar) findViewById(R.id.mytoolbar);
      // Inflate your menu
      mToolbar.inflateMenu(R.menu.menu_register);
  
      // Add 10 spacing on either side of the toolbar
      mToolbar.setContentInsetsAbsolute(4, 4);
  
      // Get the ChildCount of your Toolbar, this should only be 1
      int childCount = mToolbar.getChildCount();
      // Get the Screen Width in pixels
      int screenWidth = metrics.widthPixels;
  
      // Create the Toolbar Params based on the screenWidth
      Toolbar.LayoutParams toolbarParams = new Toolbar.LayoutParams(screenWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
  
      // Loop through the child Items
      for(int i = 0; i &lt; childCount; i++){
          // Get the item at the current index
          View childView = mToolbar.getChildAt(i);
          // If its a ViewGroup
          if(childView instanceof ViewGroup){
              // Set its layout params
              childView.setLayoutParams(toolbarParams);
              // Get the child count of this view group, and compute the item widths based on this count &amp; screen size
              int innerChildCount = ((ViewGroup) childView).getChildCount();
              int itemWidth  = (screenWidth / innerChildCount);
              // Create layout params for the ActionMenuView
              ActionMenuView.LayoutParams params = new ActionMenuView.LayoutParams(itemWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
              // Loop through the children
              for(int j = 0; j &lt; innerChildCount; j++){
                  View grandChild = ((ViewGroup) childView).getChildAt(j);
                  if(grandChild instanceof ActionMenuItemView){
                      // set the layout parameters on each View
                      grandChild.setLayoutParams(params);
                  }
              }
              }
          }
      }
  }
  </code></pre>
  
  <p>and here is the xml for this activity  mytoolbar is the bottom toolbar:</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/pharms_list"
      android:layout_height="fill_parent"
      android:layout_width="fill_parent"
      android:orientation="vertical"
      android:layout_above="@+id/mytoolbar"&gt;
  
      &lt;ListView
          android:id="@+id/list"
          android:layout_width="fill_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
  
          android:drawSelectorOnTop="false"
          android:layout_below="@+id/first_sec"
          android:layout_alignParentEnd="true" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;android.support.v7.widget.Toolbar
      android:id="@+id/mytoolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:background="@drawable/linesup"
      app:contentInsetLeft="10dp"
      app:contentInsetRight="10dp"
      app:contentInsetStart="10dp"
      &gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>and in the manifest file I did add the  android:uiOptions="splitActionBarWhenNarrow" how I could add a menu to the top as this image?</p>
  
  <p><a href="https://i.stack.imgur.com/WZ50y.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/WZ50y.jpg" alt="enter image description here"></a></p>