FAQ Database Discussion Community


FAB on pre-lollipop devices with the new support lib

android,fab,android-design-library
The support library doc states that the version 22.2 supports FloatingActionButton on Pre-Lollipop devices. I have implemented a demo app to show a FAB on KitKat. The FAB is shown but I still can't set the elevation neither in the xml nor in the code. In the xml I get...

How to create a simple divider in the new NavigationView?

android,navigation-drawer,android-support-library,android-design-library,navigationview
Google introduced the NavigationView in the Design Support Library version 22.2.0 with which you can create a drawer very easily using a menu resource. How can I create a simple divider line between two items? Grouping the items didn't work. Creating a sub items section does create a divider line,...

Why do I need to specifically target the android.support.design library?

android,android-design-library
I'm fairly new to Android development, so I apologize beforehand. I'm a bit confused on the new Android support library. How come I can use <EditText> just fine, but in order to use <TextInputLayout>, I need to use <android.support.design.widget.TextInputLayout>? Thanks!

CollapsingToolbarLayout | Scrolling and layout issues 2

android,xml,material-design,android-design-library,collapsingtoolbarlayout
Related Questions CollapsingToolbarLayout | Scrolling and layout issues Backgroud I want to use 2 different fragments that will allow me to change the layout based on orientation and screen size Header Image (Currently just an ImageView) Scrollable content Issues The CollapsingToolbarLayout does not allow me to expand the Toolbar to...

NestedScrollView and CoordinatorLayout. Issue on Scrolling

android,android-design-library,android-coordinatorlayout
I have a strange issue with the CoordinatorLayout and the NestedScrollView )(with the design support library 22.2.0) Using a content smaller than NestedScrollView I should have a fixed content. However trying to scroll up and down the content I can obtain that the content is displaced and never again in...

How to get the current selected item position using TabLayout in Android Design Library

android,android-design-library,androiddesignsupport
I am using the android design library TabLayout in that how can I get the current selected item tab position. ViewPager pager = (ViewPager) view.findViewById(R.id.pager); MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager()); pager.setAdapter(adapter); tabLayout.setupWithViewPager(pager); ...

Customising NavigationView - Adding dynamic headerView, Android Support Design Library

android,navigation-drawer,android-design-library,androiddesignsupport,navigationview
I tried the navigationView from the new android support design library. I want to have a dynamic headerview. Basically, my headerview will show something like quote of the day. I have like around 10 quotes and i want to randomly select a quote and display in a textview in the...

Import new Android Design Support library

android,android-support-library,android-design-library
Hi i'am trying to import the new android support library like this com.android.support:support-design:22.0.0 but i got this error after sync the gradle : failed to find

Using Support Design Library in Eclipse

android,eclipse,android-support-library,floating-action-button,android-design-library
I'm working on a project that unfortunately hasn't been migrated to Android Studio yet. I want to utilize the floating action button in Google's new support.design library but I can't manage to get it included in my project. I updated the support libraries in the Android SDK Manager. First I...

Error when using any Android Design Support Library Elements

android,android-support-library,android-design-library
Error inflating anything from the design support library xml <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content"/> build.gradle dependencies { compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:design:22.2.0' compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:support-v13:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' project build.gradle buildscript { repositories { mavenCentral() }...

Android SnackBar Not Working

android,android-layout,android-design-library,snackbar
Hello everyone! I wanted to try out the new Snackbar from the official design library provided by Google. It's usage very close to a Toast so I thought it would be simple enough to try out. I've tried it out on an emulator running 5.1 as well as Samsung Galaxy...

android design library gradle null pointer exception

android,android-support-library,android-design-library
I'm trying to add android.support.design library to my project: All the interesting things in my gradle file: dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:design:22.2.0' compile 'com.android.support:support-annotations:22.0.0' compile 'com.android.support:support-v13:22.1.1' compile 'com.android.support:recyclerview-v7:22.1.1' compile 'com.android.support:cardview-v7:22.1.0' } I'm getting Error:Android Gradle Build Target: java.lang.NullPointerException When removing...

Prevent toolbar from hiding when recyclerview has one item

android,toolbar,recyclerview,android-design-library
I have some, problem. The toolbar is hiding when recyclerview has few items (1,2,3,4). This is unwanted behavior. How can i prevent the toolbar from hiding when recyclerview has only few item and there is no scroll on recyclerview? main_recyclerview.xml GIF showing the problem <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="1dp" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"...

Android NavigationView menu group divider

android,navigation-drawer,android-design-library
Android support design library provide NavigationView: <android.support.design.widget.NavigationView ... app:menu="@menu/navigation_drawer_items" /> menu/navigation_drawer_items: <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item .../> ... </group> <group android:checkableBehavior="single"> <item .../> ... </group> </menu> How to add divider, separator or space between groups (like on picture)? ...

TabLayout like PagerSlidingTabStrip

android,android-design-library
I swapped out my PagerSlidingTabStrip for the new android.support.design.TabLayout and now the tabs show up in the center of the screen instead of left-aligned like they did with the PagerSlidingTabStrip. I want them to be aligned to the left of the screen like google play store on a landscape tablet...

NavigationView onClick from xml causes errors

android,navigation-drawer,android-resources,android-design-library,navigationview
Using NavigationView from the newly released Android support design library, if a navigation header layout includes an onClick (in the xml), onClick event crashes app. OnClick can be added programmatically via view.onClickListener (instead of xml), and then clicking works fine. But for some reason, whenever xml onClick is used, there...

Design Support Library v22.2 “UNEXPECTED-TOP-LEVEL EXCEPTION”

android,gradle,android-support-library,build.gradle,android-design-library
I decided to use some cool stuff Google just released in their support design library. Everythyng goes fine when I import the library and when I sync the project with Gradle files. But it gives me an error when I compile the project. I don't know if i have too...

What is CoordinatorLayout?

android,android-support-library,android-design-library
Just had a look at the demo app of new Android support design library. It's provided by Chris Banes on github. Throught the app, CoordinatorLayout is used Heavily. Also, many of the support design libabry classes like FloatingActionButton, SnackBar, AppBarLayout etc. behaves differently when used inside CoordinatorLayout. Can someone please...

AppBarLayout is not responding to scroll in the fragment

android,android-design-library,androiddesignsupport
I am using the new Android Support Design library. I have followed the demo on the Android Developer Blogspot except I use a fragment for RecyclerView instead of putting both in the same xml. Here's my activity_main.xml <android.support.v4.widget.DrawerLayout 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:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer_layout" >...

AppBarLayout and Toolbar invisible on Android 4.x

android,android-support-library,android-design-library
I am using the new AppbarLayout and Toolbar from the v22 design support library. But they appear invisible on 4.x devices. Is this a known issue? How do I fix it? Here's my XML: <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"...

TextInputLayout not showing EditText hint before user focus on it

android,material-design,android-design-library
I am using recently released Android Design Support Library to show floating label with EditTexts. But i am facing the problem that the Hint on the EditText is not showing when UI is rendered, but i see the Hint after i focus on the EditTexts. My Layout is as follows:...

Disable icon colorStateList in NavigationView

android,material-design,android-design-library
In my app today i have icons which doesn't just have a single color, but in some cases two colors depending on the data state in my app. This means i cant use the default tinting behavior in NavigationView. It looks like with the new NavigationView, unless i specify a...

How to create app bar with icons using TabLayout Android Design?

android-tabhost,android-tabs,android-design-library
I'm trying to use the new TabLayout in the android design library to create app bar with icons. public void setupTabLayout(TabLayout tabLayout) { tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); tabLayout.setupWithViewPager(mViewpager); tabLayout.getTabAt(0).setIcon(R.drawable.ic_tabbar_library); tabLayout.getTabAt(1).setIcon(R.drawable.ic_tabbar_recents); tabLayout.getTabAt(2).setIcon(R.drawable.ic_tabbar_favorites);...

(Design Support Library) Toolbar items behind the status bar

android,android-design-library
I am using @chrisbanes design sample: https://github.com/chrisbanes/cheesesquare the toolbar items appears behind the status bar on Lollipop only. Please note that the same error shows on the sample, check the first screenshot. ...

Android NestedScrollView has wrong size after app:layout_behavior

android,android-layout,android-design-library
Since Google has published the design support library for android, there are many nice things that can be done without implementing custom code. While i've tested the custom views in this lib, i have found a worse thing, and i didn't know if this is a bug or not. I...

How to fix the position of a view inside a ViewPager and CoordinatorLayout

android,android-layout,android-design-library,android-coordinatorlayout,coordinator-layout
I have an activity with the layout of: <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="56dp" android:layout_width="match_parent"...

How to set custom typeface to items in NavigationView?

android,android-design-library,navigationview
With the new NavigationView, we are able to set a drawer's items through a menu resource in XML. With that, we can set each item with something like <item android:id="@+id/drawer_my_account" android:icon="@drawable/ic_my_account" android:title="@string/drawer_my_account" /> But now, I want to set a custom typeface to each of those items in my drawer,...

Android Design Support Library Secondary Drawer Menu

android,navigation-drawer,android-support-library,android-design-library,androiddesignsupport
I've switched to the official Google Design Support Library. Now, I want to use a secondary menu with a divider like this: But as Android is using the Menu Inflater I have no idea what to do now. I can add a second group, but then the items have the...

How to change the floating label color of TextInputLayout

android,android-edittext,android-design-library
With reference to the new TextInputLayout released by Google, how do I change the floating label text color? Setting colorControlNormal, colorControlActivated, colorControlHighLight in styles does not help. This is what I have now: ...

ImageView in CollapsingToolbarLayout not covering full height?

android,android-layout,android-design-library,androiddesignsupport
I have some issues trying to implement the new CollapsingToolbarLayout. Scrolling, expanding and collapsing do work fine, but my ImageView (no matter what type of resource I set) does not cover the full height of the expanded toolbar. See here: Here I set android:src="@color/red" on the image view, but it...

When using the CoordinatorLayout my ScrollView has an incorrect size

android,android-support-library,material-design,android-scrollview,android-design-library
I'm using a ScrollView in a layout, and am attempting to use the new CoordinatorLayout from the design support library. My layout file looks like this: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"...

How to add submenu items to NavigationView programmatically instead of menu xml

android,android-menu,android-design-library
I'm trying to add submenu items to NavigationView programmatically . I'm able to add items into menu but not into submenu Adding items to menu works Menu menu = mNavigationView.getMenu(); menu.add(Menu.NONE, Menu.NONE, index, "Menu Item1"); But adding items to sub menu doesn't work Menu menu = mNavigationView.getMenu(); SubMenu subMenu =...

CollapsingToolbarLayout and TabLayout

android,android-design-library
I'm trying to create an activity that has a CollapsingToolbarLayout with an image and toolbar (like in the CheeseDetailActivity in the cheesesquare example here), that also has a tab layout below. Any ideas how to implement it? When trying to add it to the CollapsingToolbarLayout or the AppBarLayout, the result...

CoordinatorLayout with RecyclerView & CollapsingToolbarLayout

java,android,xml,appcompat,android-design-library
I've been attempting to implement a CollapsingToolbar with a RecyclerView using the small amount of guidance here: http://android-developers.blogspot.co.uk/2015/05/android-design-support-library.html and the project here: https://github.com/chrisbanes/cheesesquare, and I currently have the following 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/main_content"...

Android Snackbar - Changing its alignment from bottom of screen to top of screen

android,material-design,android-design-library,snackbar,android-snackbar
The recent android library came out just a few days ago, but I would like to have the SnackBar appear on top of the screen, preferably within a RelativeLayout as it's parent view. How does one change the SnackBars initial alignment which I presume to be layout_alignParentBottom to layout_alignParentTop?...

Android design support library with Theme.Material

android,android-5.0-lollipop,android-design-library,androiddesignsupport,material-theme
I would like to use the new design support library in my application beginning with the API 21. I want to use Theme.Material style but it's work only with Theme.AppCompat style. When I use Theme.Material, android return this error: error inflating class android.support.design.widget.textinputlayout" How can I resolve it ? Thank...

How to add shadow to the FAB provided with the android support design library?

android,floating-action-button,android-design-library,appcompat-v7-r22.2
The title is pretty self explaining. The following code does not render shadow below the Floating Action Button. What can be done to render shadow? Is this feature really not supported even on API 21+? <android.support.design.widget.FloatingActionButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/ic_add" android:clickable="true" /> Note: Adding android:elevation does not add shadow on API...

App won't run after adding support design library

android,android-design-library
I'm currently trying to implement the android design library on my app but after encountering a lots of problems after updating my SDK etc now I'm having trouble on actually using it. It gives me this error when running the app (gradle is already synced, clean and project rebuilt): *...

FloatingActionButton example with Support Library

android,android-support-library,floating-action-button,android-design-library
Recently, I read these posts: Android Design Support Library Android Support Library, revision 22.2.0 FloatingActionButton But, none of them give me a detail example about creating a new FloatingActionButton. So hard to understand, I asked this question. Can anyone give me an example about it? Any help much be appreciated....

CoordinatorLayout using the viewpager's recyclerview

java,android,xml,appcompat,android-design-library
I am using the view CoordinatorLayout from android.support.design my main problem is that how can you attach the app:layout_behavior to the fragments RecyclerView? In the example given by google they only attach it in the RecyclerView of the same xml file where the CoordinatorLayout was attached. Is there a way...

Snackbar in Support Library doesn't include OnDismissListener()?

android,android-support-library,android-design-library,android-snackbar
I'd like to implement the new Snackbar included in the latest Design Support Library, but the way it is offered seems counter-intuitive for my, and I assume many others', use. When the user does an important action, I want to allow them to undo it via the Snackbar, but there...

FloatingActionButton, square button below API level 17

android,material-design,android-design-library
I am using android.support.design.widget.FloatingActionButton from the new Design Support library 22.2.0, in my layout file. It is working fine but it shows a square button below API level 17 ...

How to customize item background and item text color inside NavigationView?

android,material-design,drawerlayout,android-design-library,navigationview
I wanna achieve something like this shown in the Material Design Docs. colorControlHighlight is used for the Background on checked items. I need to customize: background unchecked text color checked text color unchecked ...

How I can remove the unnecessary top padding of the Navigation view?

android,android-support-library,android-design-library,navigationview
There's an unnecessary top padding between the header and the first item shown in this picture. How it can be removed? you can find the source code here: https://github.com/chrisbanes/cheesesquare...

What is new features of Android Design Support Library and how to use its Snackbar?

android,material-design,android-design-library,android-snackbar
Android M Preview for developers was released yesterday. As usual, many amazing new features are introduced. I noticed that Snackbar is one of them. I have read the document about Snackbar, from which I learnt that Snackbar is in the library of Android Design Support Library, whose absolute path is...

getFragmentManager on android.support.design.widget.NavigationView

android,navigation-drawer,android-support-library,android-design-library
On the new support design library I cant replace current fragment, check my code below. Although the Toasts are working and displaying on the screen. I'm getting empty screen whenever I'm going to click on any item on the navigation drawer private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override...

Android Design Support Library And Material Design Backwards Compatibility?

android,android-support-library,material-design,appcompat,android-design-library
I'm new here, so bear with me! I'm sorta confused about the new Design Support Library (and how one implements support libraries), and I had a two questions: I'm confused about how support libraries are implemented. Is it something as simple as saying 'if the OS version is below version...

Android SnackBar giving exception and not working

android,android-layout,android-design-library,android-snackbar
I have tried new Snackbar from the official design library provided by Google. I have downloaded new Design library through SDK and put it into libs folder. I am using eclipse and whenever I tried to run it it gives exception. I don't want to use any extra third party...

Android TabLayout Android Design

android,android-design-library
I'm trying to get the new TabLayout in the android design library working. I'm following this post: http://android-developers.blogspot.com/2015/05/android-design-support-library.html and the documentation: http://developer.android.com/reference/android/support/design/widget/TabLayout.html And have come up with the following code in my activity but the tablayout isn't showing up when I run the activity. I tried adding in the activity...

Can't import Material Design Library in android studio

android-studio,material-design,android-design-library
I read this page, that learn "importing libraries into android studio". but it's doesn't work for me. i do those step for Material Design Library. in Material Design's build.gradle file have: https://github.com/navasmdc/MaterialDesignLibrary/blob/master/MaterialDesign/build.gradle when i click on "Sync Project with Gradle Files" it's gives me two error: Error:(2, 0) Plugin with...

Toolbar not showing with swipe to refresh

android,android-recyclerview,swiperefreshlayout,android-design-library
I'm trying to implement collapsing tollbar with swipe to refresh and recyclerview. When I'm trying to scroll (when recyclerview has only one item) toolbar collapse, but when I'm trying to scroll down to show toolbar, it's impossible because swipe down causes swipe to refresh. When recyclerview has more item it...

CoordinatorLayout layout_anchor does not work

android,recyclerview,android-design-library,coordinator-layout
I just tried out the new Support Design Library with CoordinatorLayout, but I'm having problems anchoring child views. My layout currently looks like this: <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/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar"...

How to use TextInputLayout in new android design library [closed]

android,android-design-library
Recently google introduced new android design library in that how to use TextInputLayout field. How do we use it?...

Is there a native component for the Floating action button in Android Material Design?

android,material-design,floating-action-button,android-design-library
My question revolves around the Floating action button that was introduced in Android Material Design. There are many library offering this component on GitHub as: Android-floating-action-button FloatingActionButton CircularFloatingActionMenu Fab Floating-action-button But my question is: Is there a native component with the last release of android.support.vX that was built for Floating...

How to use a TabLayout with Toolbar inside CollapsingToolbarLayout?

android,material-design,android-toolbar,android-design-library
I am looking at the chrisbanes/cheesesquare and I am trying to put TabLayout with a Toolbar inside a CollapsingToolbarLayout, and here is my code <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/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.v4.view.ViewPager android:id="@+id/viewpager"...

CollapsingToolbarLayout | Scrolling and layout issues

android,xml,material-design,android-design-library,collapsingtoolbarlayout
Related Questions CollapsingToolbarLayout | Scrolling and layout issues 2 Question I have been working with the Android Support Design Library and successfully implemented the CoordinatorLayout that causes the Toolbar and TabLayout to scroll out of view when scrolling. This works very well, so I figured I would try my luck...

CollapsingToolbar not working with not-so-tall content

android,android-support-library,android-design-library,androiddesignsupport
I'm pretty sure this is a bug, so I'm asking for a workaround. My layout is like: <CoordinatorLayout> <AppBarLayout> <CollapsingToolbarLayout> <ImageView/> <Toolbar/> </CollapsingToolbarLayout> </AppBarLayout> <android.support.v4.widget.NestedScrollView/> <!-- content here --> </CoordinatorLayout> I'm retrieving content from the web, and I don't know how tall it'll be - might be few lines, might...

Gradle error after add android support design library

android,android-support-library,android-design-library
I'm getting this error after add compile 'com.android.support:design:22.2.0' to my gradle file: .../app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values/values.xml with this message Error:(1) Attribute "insetForeground" has already been defined. I have this on my build.gradle file: ` compile 'com.android.support:design:22.2.0' compile 'com.android.support:cardview-v7:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' compile 'com.google.android.gms:play-services-base:7.5.0' compile...

CoordinatorLayout not working

android,material-design,android-design-library
I am attempting to implement a CoordinatorLayout from the newly announced Android Design Support Library and I have used the following code in my XML layout as per the sample here: <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/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar"...