Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a bigger Android Toolbar with advanced options?

I want to place a search into my apps Toolbar. So the user has the default Toolbar with a search action icon. When clicking it, the Toolbar should resize and get bigger or a bigger alternative slides in from above. It should show some search field and other controls in it. By exiting the search the Toolbar should resize back to default or slide out.

Google Maps uses something similar (not exactly, maybe it's not a Toolbar at all but it looks like) when you press the blue floating action button:

Google Maps Navigation

Is there a best practice for this? How to do this?

like image 877
Michael Avatar asked Jan 07 '16 09:01

Michael


People also ask

What is the difference between a toolbar and an action bar?

The Toolbar is basically the advanced successor of the ActionBar. It is much more flexible and customizable in terms of appearance and functionality. Unlike ActionBar, its position is not hardcoded i.e., not at the top of an activity.

How do you get to the toolbar menu on android?

Make a menu xml This is going to be in res/menu/main_menu . Right click the res folder and choose New > Android Resource File. Type main_menu for the File name. Choose Menu for the Resource type.


1 Answers

Make a custom toolbar and add buttons,images,textview in it and than add it to your Activities

<?xml version="1.0" encoding="utf-8"?>
   <android.support.v7.widget.Toolbar
   android:layout_height="150dp"
   android:layout_width="match_parent"
   android:background="@color/ColorPrimary"
   android:elevation="0dp"
   android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
   xmlns:android="http://schemas.android.com/apk/res/android" >
</android.support.v7.widget.Toolbar> 

and inside your activity

Toolbar mToolbar = (Toolbar) findViewById(R.id.tool_bar);
this.setSupportActionBar(mToolbar);
like image 122
Muhammad Younas Avatar answered Sep 28 '22 11:09

Muhammad Younas