android-toolbar

How to add item number on the cart icon at top toolbar? Android

余生长醉 提交于 2019-12-05 10:33:15
I saw some apps made it. So I am intersting at how to do it. I believe there must be some trick way to do it. Example: I add the cart icon in the menu file. ` <item android:id="@+id/action_drawer_search" android:orderInCategory="300" android:title="Search" android:icon="@drawable/ic_search_white_24dp" app:showAsAction="ifRoom" /> <item android:id="@+id/action_drawer_cart" android:orderInCategory="200" android:title="Cart" android:icon="@drawable/ic_shopping_cart_white_24dp" app:showAsAction="ifRoom"/> ` Example code that worked for me. 1: Create a layout for your badge menu item.

Hiding Toolbar on scroll with recyclerview inside fragment

*爱你&永不变心* 提交于 2019-12-05 08:56:52
问题 I'm trying to get the toolbar to collapse on scroll when a recyclerview inside a fragment is scrolled. To start, heres my main layout: <DrawerLayout> <RelativeLayout android:id="@+id/mainRelativeLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <android.support.design.widget.AppBarLayout android:id="@+id/appBarLayout" android:layout_width

Removing left margin from android navigation drawer icon

走远了吗. 提交于 2019-12-05 08:46:46
Can anybody help me to find the way to remove the left margin of the navigation drawer icon (mentioned by red rectangle below )? I am using toolbar here. This removes the left margin from toolbar. mainToolbar.setContentInsetsAbsolute(0, 0); Or you can set left inset to 0dp in toolbar xml: android:contentInsetLeft="0dp" Other way is to define that padding in the styles.xml: <style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar"> <item name="contentInsetStart">0dp</item> <item name="android:contentInsetStart">0dp</item> </style> If all of these solutions didn't worked please check

Android 5.0 - How to implement this tablet layout from Material Design guidelines

不羁岁月 提交于 2019-12-05 07:46:31
问题 I am not getting it which is ActionBar and which is ToolBar. How do i implement this? Any answers appreciated..Thanks in Advance. 回答1: In this example, the blue toolbar is an extended height, overlaid by the screen content and provides the navigation button. There is another toolbar used in the detail view. I have circled both Toolbars below. 回答2: Haven't tried this yet but it should work. Here is your layout : <?xml version="1.0" encoding="utf-8"?> <!-- The important thing to note here is

Android Multiline Toolbar Title

你离开我真会死。 提交于 2019-12-05 06:18:01
I have a Toolbar that when in landscape mode isn't as wide as usual, but it has more height than usual and for that reason I want to set the title to be multiline (2 lines to be precise) when it is in landscape. I have tried some things where I put a TextView inside of the Toolbar, but when I try to access the TextView to set it's title (since the the title is variable) I get a NullPointer after using findViewById. Here is some code of the current situation (without multiline): @Override protected void onResume() { super.onResume(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2);

Toolbar: IllegalStateException - configure your build for VectorDrawableCompat

老子叫甜甜 提交于 2019-12-05 06:02:30
I'm using Android Studio 2.1.2. I started a new project with minSdkVersion as 19. My activity extends AppCompatActivity. The project starts with an empty activity using a fragment. When previewing content_main.xml with API 24, all is good. when previewing API 19, I get the following rendering problem: The following classes could not be instantiated: - android.support.v7.widget.Toolbar java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat I have added every thing I found relevant to the gradle (2 files):

Toolbar not hiding on RecyclerView scroll

风流意气都作罢 提交于 2019-12-05 04:18:16
I'm trying to make the Toolbar in my app hide and show based on the RecyclerView 's scrolling. This gif shows what I'm trying to achieve. I'm following this tutorial and not getting the results I'm looking for. Here is my activity's layout: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:fitsSystemWindows="true"> <android.support.v4.widget

How to implement WhatsApp like material design SearchView?

﹥>﹥吖頭↗ 提交于 2019-12-05 02:08:02
问题 WhatsApp has such Toolbar: When 'Search' menu item clicked, from the top SearchView comes down which takes whole space of toolbar: When I tried to implement SearchView, it looks like this: I found some libraries to implement this: Android Material SearchView by Eugene Horan and MaterialSearchView by krishnakapil. But they are not like in WhatsApp. This question may seem weird, I could not find the way how to do this. So my question is how to implement WhatsApp like material design SearchView

How to set Android toolbar height?

我们两清 提交于 2019-12-05 01:27:16
I want to achieve this: What I thought was to make a Custom Toolbar with a bigger height and work with the tabhost and tabpager normally. I have implemented it, but the toolbar is showing the normal height, so it doesn't show as I want, just the top part. Is this the right approach or is it possible to set a TabHost below a Linear/Relative Layout? Because I don't need to work with it as an action bar. Relevant Code toolbar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbarTitle"

Access Toolbar (and its children) from fragment?

£可爱£侵袭症+ 提交于 2019-12-05 01:04:36
问题 I'm building an application using the v7.widget.Toolbar component. I'm able to add the toolbar to my activity, but I don't know how (and what is the right way?) to access it from the activity's fragment. Here's the toolbar <android.support.v7.widget.Toolbar 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" android:id="@+id/toolbar" app:theme="@style/MainActionBar" android:layout_width=