Toolbar and Contextual ActionBar with AppCompat-v7

Update: Solution: use the windowActionModeOverlay property. Set this in your theme: <item name=”windowActionModeOverlay”>true</item> and the actionmode will be shown over the action bar instead of pushing it down. (If you’re not using the latest AppCompat then you need to add the “android:” prefix to the property). It basically lets AppCompat know that you have a … Read more

Is it possible to change the textcolor on an Android SearchView?

Add <item name=”android:editTextColor”>@android:color/white</item> to the parent theme and that should change the entered text. You can also use <item name=”android:textColorHint”>@android:color/white</item> to change the hint text color for the SearchView. (Note that you can replace the @android:color/white with whatever appropriate value you’re hoping to use)

Change Toolbar color in Appcompat 21

again this is all in the link you supplied to change the text to white all you have to do is change the theme. use this theme <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/activity_my_toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:minHeight=”?attr/actionBarSize” android:background=”?attr/colorPrimary” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light”/>

No shadow by default on Toolbar?

I ended up setting my own drop shadow for the toolbar, thought it might helpful for anyone looking for it: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”top” android:orientation=”vertical”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@color/color_alizarin” android:titleTextAppearance=”@color/White” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”/> <FrameLayout android:layout_width=”match_parent” android:layout_height=”match_parent”> <!– **** Place Your Content Here **** –> <View android:layout_width=”match_parent” android:layout_height=”5dp” android:background=”@drawable/toolbar_dropshadow”/> </FrameLayout> </LinearLayout> @drawable/toolbar_dropshadow: <?xml version=”1.0″ encoding=”utf-8″?> … Read more

android lollipop toolbar: how to hide/show the toolbar while scrolling?

As far as I know there is nothing build in that does this for you. However you could have a look at the Google IO sourcecode, especially the BaseActivity. Search for “auto hide” or look at onMainContentScrolled In order to hide the Toolbar your can just do something like this: toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start(); If you want … Read more

Creating a Preference Screen with support (v21) Toolbar

Please find the GitHub Repo: Here A bit late to the party, but this is my solution that I am using as a work around continuing to use PreferenceActivity: settings_toolbar.xml : <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/toolbar” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:minHeight=”?attr/actionBarSize” app:navigationContentDescription=”@string/abc_action_bar_up_description” android:background=”?attr/colorPrimary” app:navigationIcon=”?attr/homeAsUpIndicator” app:title=”@string/action_settings” /> SettingsActivity.java : public class SettingsActivity extends PreferenceActivity { … Read more

How to make Toolbar transparent?

Create your toolbar.xml file with background of AppBarLayout is @null <?xml version=”1.0″ encoding=”utf-8″?> <android.support.design.widget.AppBarLayout android:id=”@+id/general_appbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@null” xmlns:android=”http://schemas.android.com/apk/res/android”> <android.support.v7.widget.Toolbar android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize”> <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:gravity=”center_horizontal” android:text=”Login” android:textSize=”20sp”/> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> and here is result:

Creating a button in Android Toolbar

ToolBar with Button Tutorial 1 – Add library compatibility inside build.gradle dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) compile ‘com.android.support:appcompat-v7:21.0.3’ } 2 – Create a file name color.xml to define the Toolbar colors <?xml version=”1.0″ encoding=”utf-8″?> <resources> <color name=”ColorPrimary”>#FF5722</color> <color name=”ColorPrimaryDark”>#E64A19</color> </resources> 3 – Modify your style.xml file <resources> <!– Base application theme. –> <style … Read more

How to use SearchView in Toolbar Android

You have to use Appcompat library for that. Which is used like below: dashboard.xml <menu xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” xmlns:app=”http://schemas.android.com/apk/res-auto”> <item android:id=”@+id/action_search” android:icon=”@android:drawable/ic_menu_search” app:showAsAction=”always|collapseActionView” app:actionViewClass=”androidx.appcompat.widget.SearchView” android:title=”Search”/> </menu> Activity file (in Java): public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.dashboard, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = null; if (searchItem … Read more