0


I want to implement something like this but my current view already has a Floating Action Button on it so what I'd like to do is when the user clicks on any marker on the map then a this new View with the Floating Action Button will slide up from bottom of the screen moving the already existing Floating Action Button up while the view is sliding up to make space for itself.

How can I achieve this without using any 3rd party library and just using standard components? Thanks in advance.

Update: I am targeting api level 22; so using bottom sheets is out of scope. I recon that google maps app under api level 22 had bottom sheets kind of feature when one clicks on a POI marker.

beerBear
  • 969
  • 2
  • 17
  • 41
  • You can add custom view to snackbar. and put the entire activity view inside coordinator layout – Devanshu Dwivedi Mar 17 '16 at 05:43
  • @DevanshuDwivedi We shouldn't customize the snackbar as per [Google Material Design Guidelines](https://www.google.com/design/spec/components/snackbars-toasts.html#) Also, a snackbar will timeout by default; customizing it and showing it forever is another thing. See this answer [here](http://stackoverflow.com/a/33229593/1184579). Thanks for the idea though :) – beerBear Mar 17 '16 at 05:47
  • you can take a view and make its visibility gone and on click on marker make it visible.. i dont know it will work or not but you can try once. because you can not edit snackbar and you don't want 3rd party too. – Jishant Mar 17 '16 at 05:52
  • @Ancee can I make a snackbar having a FAB anchored to it? and a pull up kind of action similar to one visible on google maps App? – beerBear Mar 19 '16 at 11:54

1 Answers1

2
  1. You can use a bottom sheet to make the new view inside a coordinator layout.
  2. Reference the id of the view wich has set the BottomSheetBehavior with the layout_anchor attribute of the FAB. Example: app:layout_anchor="@id/app_bar"
  3. Configure the layout_anchorGravity attribute with the desired gravity. Example: app:layout_anchorGravity="bottom|end"

Look here for more

Santhosh
  • 3,781
  • 2
  • 14
  • 11
  • thanks for the reply but is there any way I can make the existing floating action bar move up when I add a bottom sheet with another action button on it? – beerBear Mar 17 '16 at 07:28
  • You want to have two FAB's then? This is discouraged in the guidelines! – Santhosh Mar 17 '16 at 09:29
  • can you refer me to the place where you got that info from? if you have a look at google maps then you will see two FABs one for user's location and the other for navigation. – beerBear Mar 17 '16 at 09:37
  • I just checked that Bottom sheets are only available in api level 23 and above; is there an alternative? Thanks. – beerBear Mar 17 '16 at 10:15
  • Bottom sheets are available in [support library 23.2](http://android-developers.blogspot.nl/2016/02/android-support-library-232.html) so can be used till v7. For the other question, read the [guidelines](https://www.google.com/design/spec/components/buttons-floating-action-button.html#buttons-floating-action-button-floating-action-button) – Santhosh Mar 18 '16 at 05:06
  • yes bottom sheets are only available in api level 23 but I am targeting 22; hence my question of using standard components. Google maps app under api level 22 also had a similar feature(bottom sheets) if one clicks on a POI marker..maybe they had non-generic component for the same – beerBear Mar 18 '16 at 09:04
  • Hey @beerBear, please read what a support library is. It supports till api 7. – Santhosh Mar 18 '16 at 10:27
  • I am aware of what a support lib is but the fact that you missed is : for example "if one is targeting SDK level 21 then it is **best** recommended to use parallel version of the support library i.e. 21.x.. as the library itself needs to be aligned with whatever methods are available in targeted SDK level otherwise there might be serious bugs cropping up at compile & runtime. So, in my case if I am targeting SDK level 22 then I should be using support library v.22.x.x instead of v.23. See this [answer](http://stackoverflow.com/a/32942918/1184579) by a fellow exGoogle Engineer. – beerBear Mar 19 '16 at 11:52