Android v7 Toolbar button alignment

You should add android:layout_gravity=”end” for your Button : <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”end” android:id=”@+id/showevents” android:textSize=”12sp” android:background=”@null” android:layout_alignParentEnd=”true” android:layout_alignParentRight=”true” android:textColor=”#FFF” android:text=”UPCOMING \nEVENTS”/>

Toolbar.inflateMenu seems to do nothing

If you are calling setSupportActionBar() you don’t need to use toolbar.inflateMenu() because the Toolbar is acting as your ActionBar. All menu related callbacks are via the default ones. The only time you need to call toolbar.inflateMenu() is when you are using the Toolbar as a standalone widget. In this case you will also have to … Read more

How can I align Android Toolbar menu/icons to the left like in Google Maps app?

After some struggling and digging in Android Toolbar code I managed to make it work. Basically, the idea is to add a new android.support.v7.widget.ActionMenuView as child of the Toolbar, set its gravity to top|start, and then add the menu to that action menu view in your Activity. Here is the code: my_toolbar.xml <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” … Read more

Manage toolbar’s navigation and back button from fragment in android

Add a toolbar to your xml <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:background=”?attr/colorPrimary” android:theme=”@style/ThemeOverlay.AppCompat.ActionBar” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light”> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Fragment title”/> </android.support.v7.widget.Toolbar> Then inside your onCreateView method in the Fragment: Toolbar toolbar = view.findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_back_button); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().onBackPressed(); } });

Android – Switch ActionBar Back Button to Navigation Button

If I assume you’re using android.support.v4.widget.DrawerLayout in your layout, then this approach may work for you; I’ve only tested on API 21 but given it’s mostly using the support libraries, it should work (famous last words) on lower or higher targets. import android.support.v7.app.ActionBarDrawerToggle import android.support.v4.widget.DrawerLayout ActionBarDrawerToggle mDrawerToggle; DrawerLayout drawerLayout; private boolean mToolBarNavigationListenerIsRegistered = false; @Override … Read more

Fix bottom bar in CoordinatorLayout

Try this layout : <?xml version=”1.0″ encoding=”utf-8″?> <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:id=”@+id/container”> <ScrollView android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_above=”@+id/bottom_navigation” android:layout_alignParentTop=”true”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical”> <android.support.v7.widget.CardView xmlns:card_view=”http://schemas.android.com/apk/res-auto” android:id=”@+id/card_view” android:layout_width=”match_parent” android:layout_margin=”10dp” android:layout_height=”110dp” android:padding=”15dp” card_view:cardElevation=”2dp” card_view:cardCornerRadius=”4dp”> <TextView android:layout_width=”match_parent” android:layout_height=”match_parent” android:text=”Test” /> </android.support.v7.widget.CardView> <android.support.v7.widget.CardView xmlns:card_view=”http://schemas.android.com/apk/res-auto” android:id=”@+id/card_view1″ android:layout_width=”match_parent” android:layout_margin=”10dp” android:layout_height=”110dp” android:padding=”15dp” card_view:cardElevation=”2dp” card_view:cardCornerRadius=”4dp”> <TextView android:layout_width=”match_parent” android:layout_height=”match_parent” android:text=”Test” /> </android.support.v7.widget.CardView> <android.support.v7.widget.CardView xmlns:card_view=”http://schemas.android.com/apk/res-auto” … Read more