Giter VIP home page Giter VIP logo

material-sheet-fab's Introduction

MaterialSheetFab

Maven Central Codacy Badge GitHub license Android Arsenal Android Weekly

Library that implements the floating action button to sheet transition from Google's Material Design documentation. It can be used with any FAB library on Android 4.0+ (API levels >= 14).

Transition

Installation

Gradle

Add the dependency (available from mavenCentral and jcenter) to your build.gradle:

implementation 'com.gordonwong:material-sheet-fab:1.2.1'

Proguard

Modify your proguard configuration (if your app is using Proguard).

-keep class io.codetail.animation.arcanimator.** { *; }

Usage

Implement the FAB:

You can use any FAB library as long as it implements the AnimatedFab interface.

import android.support.design.widget.FloatingActionButton;

public class Fab extends FloatingActionButton implements AnimatedFab {

   /**
    * Shows the FAB.
    */
    @Override
    public void show() {
        show(0, 0);
    }

    /**
     * Shows the FAB and sets the FAB's translation.
     *
     * @param translationX translation X value
     * @param translationY translation Y value
     */
    @Override
    public void show(float translationX, float translationY) {
        // NOTE: Using the parameters is only needed if you want
        // to support moving the FAB around the screen.
        // NOTE: This immediately hides the FAB. An animation can 
        // be used instead - see the sample app.
        setVisibility(View.VISIBLE);
    }

    /**
     * Hides the FAB.
     */
    @Override
    public void hide() {
        // NOTE: This immediately hides the FAB. An animation can
        // be used instead - see the sample app.
        setVisibility(View.INVISIBLE);
    }
}

Modify the layouts:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   <!-- Your FAB implementation -->
   <path.to.your.fab
        android:id="@+id/fab"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true" />

    <!-- Overlay that dims the screen -->
    <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
        android:id="@+id/overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Circular reveal container for the sheet -->
    <io.codetail.widget.RevealLinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="end|bottom"
        android:orientation="vertical">

        <!-- Sheet that contains your items -->
        <android.support.v7.widget.CardView
            android:id="@+id/fab_sheet"
            android:layout_width="250dp"
            android:layout_height="300dp">
            
            <!-- TODO: Put your sheet items here -->
            
        </android.support.v7.widget.CardView>
    </io.codetail.widget.RevealLinearLayout>
</RelativeLayout>

Initialize the MaterialSheetFab:

This can be in your Activity or Fragment.

public class MaterialSheetFabActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Fab fab = (Fab) findViewById(R.id.fab);
        View sheetView = findViewById(R.id.fab_sheet);
        View overlay = findViewById(R.id.dim_overlay);
        int sheetColor = getResources().getColor(R.color.fab_sheet_color);
        int fabColor = getResources().getColor(R.color.fab_color);

        // Initialize material sheet FAB
        materialSheetFab = new MaterialSheetFab<>(fab, sheetView, overlay,
            sheetColor, fabColor);
    }
}

Optional:

Close sheet on back button:

@Override
public void onBackPressed() {
    if (materialSheetFab.isSheetVisible()) {
        materialSheetFab.hideSheet();
    } else {
        super.onBackPressed();
    }
}

Listen to events:

materialSheetFab.setEventListener(new MaterialSheetFabEventListener() {
    @Override
    public void onShowSheet() {
        // Called when the material sheet's "show" animation starts.
    }
    
    @Override
    public void onSheetShown() {
        // Called when the material sheet's "show" animation ends.
    }

    @Override
    public void onHideSheet() {
        // Called when the material sheet's "hide" animation starts.
    }
     
    public void onSheetHidden() {
        // Called when the material sheet's "hide" animation ends.
    }
});

Move the FAB around the screen (this is useful for coordinating with snackbars):

materialSheetFab.showFab(translationX, translationY);

Sample app

Get it on Google Play

Sample 1 Sample 2

Take a look at the sample code and try the app.

Apps using MaterialSheetFab

Feel free to open a pull request to include your app here.

Icon App
BG Monitor BG Monitor - Diabetes Management

Changelog

See changelog here.

Credits

The following libraries are used:
CircularReveal - Adds circular reveal animation on Android versions < 5.0
ArcAnimator - Used to animate FAB in an arc

License

The MIT License (MIT)

Copyright (c) 2015 Gordon Wong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

material-sheet-fab's People

Contributors

ardacebi avatar gowong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

material-sheet-fab's Issues

Not working on S3

On S3, when click on FAB, the sheet show at the top corner and just a small part visible. When click somewhere else on screen trying to cancel the sheet, FAB button stays hidden. I'm using the FAB implementation from your sample app.

Sheet is not showing first time

when start app and click on fab then it hide hole sheet fist time but when i click on another time then sheet showing properly what is the problem i dnt know

Was working properly before update android studio 3.0

After updating android studio that is working properly with api level 21+ but with api level 15 that shows exception like --

java.lang.NoClassDefFoundError: io.codetail.animation.arcanimator.Side at com.gordonwong.materialsheetfab.MaterialSheetFab.getFabArcSide(MaterialSheetFab.java:319) at com.gordonwong.materialsheetfab.MaterialSheetFab.morphIntoSheet(MaterialSheetFab.java:269) at com.gordonwong.materialsheetfab.MaterialSheetFab.showSheet(MaterialSheetFab.java:169) at com.gordonwong.materialsheetfab.MaterialSheetFab$1.onClick(MaterialSheetFab.java:104)

Fab is located in a wrong spot on < 5.0 devices

I have followed your sample code and created my own view, but the fab is located in a wrong place. With the "show layout bounds" enabled in debugging mode, I can see that the fab has some padding on < 5.0 devices. Any idea what might causing the issue?

screen shot 2016-03-14 at 5 47 32 pm

screen shot 2016-03-14 at 5 48 01 pm

java.lang.NullPointerException: isSheetVisible()

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.gordonwong.materialsheetfab.MaterialSheetFab.isSheetVisible()' on a null object reference

    @Override
    public void onBackPressed() {
        if (materialSheetFab.isSheetVisible()) {
            materialSheetFab.hideSheet();
        } else {
            super.onBackPressed();
        }
    }

Sorry, I found a problem. ๐Ÿ˜„

Sheet is not hiding after fast item click

Steps to reproduce in the sample:

  1. Click FAB to open the sheet.
  2. Immediately (with no delay) click on some item, for example, "Recording".
  3. The toast "Item pressed" appears but the sheet is not hiding.

Circular reveal animation too fast when hiding sheet

On a Nexus 5 with android 6.0.1, the circular reveal works fine when clicking on the fab but plays too fast when it's reversed to hide the sheet.

I first saw that behavior in the app I'm coding using your great library but could witness it in the sample applicaiton as well. Maybe that's the intended behavior but it doesn't match the 'preview' visible in the readme.

No resources found

I tried using 1.2.1 and 1.0.4 version. I got below error in both versions.

Error:(2174, 21) No resource found that matches the given name: attr 'cardBackgroundColor'. Error:(2175, 21) No resource found that matches the given name: attr 'cardCornerRadius'. Error:(2173, 21) No resource found that matches the given name: attr 'contentPadding'. Error:(2193, 21) No resource found that matches the given name: attr 'cardBackgroundColor'. Error:(2194, 21) No resource found that matches the given name: attr 'cardElevation'. Error:(2195, 21) No resource found that matches the given name: attr 'cardMaxElevation'. Error:(2196, 21) No resource found that matches the given name: attr 'contentPadding'. Error:(2174, 21) No resource found that matches the given name: attr 'cardBackgroundColor'. Error:(2175, 21) No resource found that matches the given name: attr 'cardCornerRadius'. Error:(2173, 21) No resource found that matches the given name: attr 'contentPadding'. Error:(2193, 21) No resource found that matches the given name: attr 'cardBackgroundColor'. Error:(2194, 21) No resource found that matches the given name: attr 'cardElevation'. Error:(2195, 21) No resource found that matches the given name: attr 'cardMaxElevation'. Error:(2196, 21) No resource found that matches the given name: attr 'contentPadding'.

How can I call AlertDialog.Builder after pressing Fab button?

Hi, congratulations for the good job!

I have a question though...

I would like to use Android built-in AlertDialog, and generally I set the title and message using AlertDialog.Builder in the Activity code.

How can I do it in a way the user press the Fab button, and it gets animated to show alert dialog instead of a CardView, as shown in the examples?

SHEET POSITION CENTER -- NOT TO RIGHTMOST CORNER

Hi, it doesn't to allow flexible positioning , is there to override it , so instead to enlarging in the leftmost corner it on the center above the fab(which is also position at the center)

Looking the source code it seem this is the method to override
setFabAnchor

Problems after applying animation to Fab

Hi

I am applying an animation to the Fab to hide/show it when a list is scrolled. I apply the animation as so:

fab.startAnimation(anim)

The Fab animates correctly however when you tap the Fab after it has been animated the Fab does not transition into the material sheet correctly. Instead the Fab button grows in size and is drawn above the material sheet. Tapping it several more times makes it grow even larger until the app crashes with this exception:

OpenGLRenderer: Error: Ambient Vertex Buffer overflow!!! used 480, total 320

Is there a way to reinitialise the Fab after an animation has been applied to it?

Thanks in advance.

Sample App: Resource Not Found Exception

I keep getting this:
FATAL EXCEPTION: main
Process: com.gordonwong.materialsheetfab.sample, PID: 3563
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1351)
at android.content.res.Resources.getDrawable(Resources.java:804)
at android.content.Context.getDrawable(Context.java:458)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:177)
at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:170)
at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:53)
at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:74)
at com.gordonwong.materialsheetfab.sample.adapters.NotesAdapter.onBindViewHolder(NotesAdapter.java:52)
at com.gordonwong.materialsheetfab.sample.adapters.NotesAdapter.onBindViewHolder(NotesAdapter.java:22)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5212)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5245)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4483)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359)
at android.support.v7.widget.LayoutState.next(LayoutState.java:86)
at android.support.v7.widget.StaggeredGridLayoutManager.fill(StaggeredGridLayoutManager.java:1423)
at android.support.v7.widget.StaggeredGridLayoutManager.onLayoutChildren(StaggeredGridLayoutManager.java:610)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1133)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at

Readme Fab sample

Sample class of Fab shown in README should contain all three defaulf constructors:

public Fab(Context context) {
        super(context);
    }

public Fab(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

public Fab(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

IDE yells that class has no default constructor but a programmer who has no idea how widgets are implemented can run into XML inflating error when implementing only one constructor.

how to delete notes

Is it possible to implement on note click listener ?

I want to delete note on some event (either long press or onClick event)(its not demonstrated in sample app too)

Is that possible ??

IllegalStateException: Cannot start this animator on a detached view

This error appeared in my Crashlytics log's, I dont know how to reproduce it though

Fatal Exception: java.lang.IllegalStateException 
Cannot start this animator on a detached view!

android.view.RenderNode.addAnimator (RenderNode.java:786) 
android.view.RenderNodeAnimator.setTarget (RenderNodeAnimator.java:300) 
android.view.RenderNodeAnimator.setTarget (RenderNodeAnimator.java:282) 
android.animation.RevealAnimator.<init> (RevealAnimator.java:37) 
android.view.ViewAnimationUtils.createCircularReveal (ViewAnimationUtils.java:71) 
com.gordonwong.materialsheetfab.animations.MaterialSheetAnimation.startCircularRevealAnim (MaterialSheetAnimation.java:188) 
com.gordonwong.materialsheetfab.animations.MaterialSheetAnimation.revealSheetWithFab (MaterialSheetAnimation.java:173) 
com.gordonwong.materialsheetfab.animations.MaterialSheetAnimation.morphFromFab (MaterialSheetAnimation.java:141) 
com.gordonwong.materialsheetfab.MaterialSheetFab$7.run (MaterialSheetFab.java:280) 
android.os.Handler.handleCallback (Handler.java:751) 
android.os.Handler.dispatchMessage (Handler.java:95) 
android.os.Looper.loop (Looper.java:154) 
android.app.ActivityThread.main (ActivityThread.java:6154) 
java.lang.reflect.Method.invoke (Method.java) 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:867) 
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757) 

Error inflating class com.gordonwong.materialsheetfab.sample.Fab

Hi @gowong

Thanks for the amazing library.

I tried to use your library in your project.
(Initially i tried to copy-paste the sample app files to test the library)

But i'm getting this error
11-19 17:31:48.186 11272-11272/com.roshu.testing123 E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.roshu.testing123/com.roshu.testing123.MainActivity}: android.view.InflateException: Binary XML file line #44: Error inflating class com.gordonwong.materialsheetfab.sample.Fab

This is my XML file (I took it directly from sample app):

<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
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">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- Toolbar -->
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                style="@style/Widget.MaterialSheetFab.ToolBar" />

            <!-- Tabs -->
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                style="@style/Widget.MaterialSheetFab.TabLayout" />
        </android.support.design.widget.AppBarLayout>

        <!-- View pager -->
        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/appbar"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    </android.support.design.widget.CoordinatorLayout>

    <!-- Your FAB implementation -->
    <com.gordonwong.materialsheetfab.sample.Fab
        android:id="@+id/fab"
        style="@style/Widget.MaterialSheetFab.Fab"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true" />

    <!-- Overlay that dims the screen -->
    <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
        android:id="@+id/overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Circular reveal container for the sheet -->
    <io.codetail.widget.RevealLinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="end|bottom"
        android:orientation="vertical">

        <!-- Sheet that contains your items -->
        <android.support.v7.widget.CardView
            android:id="@+id/fab_sheet"
            style="@style/Widget.MaterialSheetFab.Sheet">

            <!-- Sheet items -->
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <!-- Recording -->
                <TextView
                    android:id="@+id/fab_sheet_item_recording"
                    style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
                    android:drawableLeft="@drawable/ic_mic_grey600_24dp"
                    android:drawableStart="@drawable/ic_mic_grey600_24dp"
                    android:text="@string/recording" />

                <!-- Reminder -->
                <TextView
                    android:id="@+id/fab_sheet_item_reminder"
                    style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
                    android:drawableLeft="@drawable/ic_access_alarms_grey600_24dp"
                    android:drawableStart="@drawable/ic_access_alarms_grey600_24dp"
                    android:text="@string/reminder" />

                <!-- Photo -->
                <TextView
                    android:id="@+id/fab_sheet_item_photo"
                    style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
                    android:drawableLeft="@drawable/ic_photo_camera_grey600_24dp"
                    android:drawableStart="@drawable/ic_photo_camera_grey600_24dp"
                    android:text="@string/photo" />

                <!-- Note -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/theme_accent">

                    <TextView
                        android:id="@+id/fab_sheet_item_note"
                        style="@style/TextAppearance.MaterialSheetFab.Sheet.Item"
                        android:drawableLeft="@drawable/ic_create_grey600_24dp"
                        android:drawableStart="@drawable/ic_create_grey600_24dp"
                        android:text="@string/createnote" />
                </LinearLayout>

            </LinearLayout>

        </android.support.v7.widget.CardView>

    </io.codetail.widget.RevealLinearLayout>

    <!-- Snackbar -->
    <LinearLayout
        android:id="@+id/snackbar"
        style="@style/Widget.MaterialSheetFab.Snackbar"
        android:layout_alignParentBottom="true">

        <TextView
            style="@style/TextAppearance.MaterialSheetFab.Snackbar.Message"
            android:text="@string/snackbar_shared_msg" />

        <TextView
            style="@style/TextAppearance.MaterialSheetFab.Snackbar.Action"
            android:text="@string/view" />
    </LinearLayout>
</RelativeLayout>

<!--<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/layout_drawer_header" />-->

</android.support.v4.widget.DrawerLayout>

Thanks for any help :)

Edit:

i imported library using build.gradle file.
(i didn't actually copied the library to studio)

FAB shift

FAB is shifted to the left after many clicks on it. Steps to reproduce in the sample 1.0.3:

  1. Click on FAB to open the sheet.
  2. Close the sheet using Back key or touching outside the sheet.
  3. Repeat steps 1 and 2 many times (maybe 20 or more).
  4. FAB is shifted to the left relatively of its initial position.

Error: Program type already present: io.codetail.widget.RevealLinearLayout

When I add material sheet fab dependency 'com.gordonwong:material-sheet-fab:1.2.1' i can't build my project. Build fails with this message:

Error: Program type already present: io.codetail.widget.RevealLinearLayout

I've also tried inserting dependency in this way, without success:

implementation 'com.gordonwong:material-sheet-fab:1.2.1', {
exclude group: 'io.codetail.widget', module: 'RevealLinearLayout'
}

Problem with margin on FAB

Thanks for your job.

There is a problem when I set a margin to the FAB.
I try to use your component with a fullscreen sheet and if I have a margin on the FAB the sheet is shifted. (regarding to the fab margins)

Not working correctly when the Fab is on the left side for RTL

Currently for RTL apps, the Floating Action Button has to be on the left side instead of right side, and this leads to showing the sheet on the left of the FAB (outside of the screen) only small part is visible, I'll try to fix this issue and create a pull request.

Expansion animation and card final position isn't following layout specification

Playing with the CardView layout_width parameter as well as the card's layout_gravity and the layout_gravity of the FAB gives unexpected results. For example, set the FAB position to bottom (center) and the card to center. The FAB click animation then expands off to either the LEFT (if the card layout_width="250dp") or the RIGHT (if the card layout_width="300dp"). With the card layout_width="match_parent" its final position is mostly off screen further to the right. The expected behavior here should be animating neither left nor right, which can be understood that the magnitude of the x translation is too large, and the material sheet animation is not properly abiding by the layout specification. The y translation magnitude likely also needs review.

Layout file:

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout
    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.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <include
            android:id="@+id/my_toolbar"
            layout="@layout/toolbar" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/my_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray90"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </android.support.v4.widget.SwipeRefreshLayout>

    <!-- FAB implementation which transforms into a sheet of material -->
    <space.shall.messenger.model.MyFab
        android:id="@+id/my_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_margin="@dimen/my_fab_margin"
        android:src="@drawable/my_icon" />

    <!-- Overlay that dims the screen when FAB is pressed -->
    <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
        android:id="@+id/dim_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Circular reveal container for the sheet -->
    <io.codetail.widget.RevealLinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical">

        <!-- Sheet that contains your items -->
        <android.support.v7.widget.CardView
            android:id="@+id/fab_sheet"
            android:layout_width="250dp"
            android:layout_height="300dp"
            android:layout_gravity="center" >
            <!-- TODO: Put your sheet items here -->
        </android.support.v7.widget.CardView>

    </io.codetail.widget.RevealLinearLayout>

</android.support.design.widget.CoordinatorLayout>

FAB throws RuntimeException: Invalid drawable added to LayerDrawable! Drawable already belongs to another owner but does not expose a constant state.

I'm having problem with the FAB, it's throws this exception and I can't find the reason...
The app is not crashing, but this error occurs twice, one after the other, and this filling my logcat with bunch of code that "hiding" the important lines.
Logcat:

W/LayerDrawable: Invalid drawable added to LayerDrawable! Drawable already belongs to another owner but does not expose a constant state.
    java.lang.RuntimeException
        at android.graphics.drawable.LayerDrawable$ChildDrawable.<init>(LayerDrawable.java:1850)
        at android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:1967)
        at android.graphics.drawable.LayerDrawable.createConstantState(LayerDrawable.java:168)
        at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:1774)
        at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:1780)
        at android.graphics.drawable.RippleDrawable.mutate(RippleDrawable.java:974)
        at android.view.View.applyBackgroundTint(View.java:20532)
        at android.view.View.setBackgroundDrawable(View.java:20403)
        at android.support.design.widget.FloatingActionButton.access$001(FloatingActionButton.java:68)
        at android.support.design.widget.FloatingActionButton$ShadowDelegateImpl.setBackgroundDrawable(FloatingActionButton.java:824)
        at android.support.design.widget.FloatingActionButtonLollipop.setBackgroundDrawable(FloatingActionButtonLollipop.java:73)
        at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:179)
        at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:151)
        at com.idomo.Fab.<init>(Fab.java:17)
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.idomo.RecipesListFragment.onCreateView(RecipesListFragment.java:48)

My FAB class:

package com.idomo;

import android.content.Context;
import android.support.design.widget.FloatingActionButton;
import android.util.AttributeSet;
import android.view.View;

import com.gordonwong.materialsheetfab.AnimatedFab;

public class Fab extends FloatingActionButton implements AnimatedFab{

  public Fab(Context context){
    super(context);
  }

  public Fab(Context context, AttributeSet attrs){
    super(context, attrs); // **The error starts here** (line 17)
  }

  public Fab(Context context, AttributeSet attrs, int defStyleAttr){
    super(context, attrs, defStyleAttr);
  }

  @Override
  public void show(){
    show(0, 0);
  }

  @Override
  public void show(float translationX, float translationY){
    setVisibility(View.VISIBLE);
  }

  @Override
  public void hide(){
    setVisibility(View.INVISIBLE);
  }
}

XML (RecipesListFragment):

<!-- Your FAB implementation -->
  <com.idomo.Fab
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="start|bottom"
    android:layout_margin="@dimen/fab_margin"
    android:backgroundTint="@color/colorPrimary"
    android:src="@drawable/ic_edit" />

  <!-- Overlay that dims the screen -->
  <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
    android:id="@+id/dim_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

  <!-- Circular reveal container for the sheet -->
  <io.codetail.widget.RevealLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="start|bottom"
    android:orientation="vertical" />

  <!-- Sheet that contains your items -->
  <android.support.v7.widget.CardView
    android:id="@+id/fab_sheet"
    android:layout_width="200dp"
    android:layout_height="wrap_content">

    <ListView
      android:id="@+id/fabMenu"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">
    </ListView>
  </android.support.v7.widget.CardView>

Thanks for helpers,
Ido.

fab hide and show

in your sample app
how to hide and show fab when recyclerView scrolls up and down?
thanks

java.lang.ClassCastException: android.support.design.widget.FloatingActionButton cannot be cast to Fab

Here is my MainActivity

    Fab fab = findViewById(R.id.fab);
    View sheetView = findViewById(R.id.fab_sheet);
    View overlay = findViewById(R.id.overlay);
    int sheetColor = getResources().getColor(R.color.fab_sheet_color);
    int fabColor = getResources().getColor(R.color.fab_color);

    // Initialize material sheet FAB
    materialSheetFab = new MaterialSheetFab<>(fab, sheetView, overlay,
            sheetColor, fabColor);
    materialSheetFab.setEventListener(new MaterialSheetFabEventListener() {
        @Override
        public void onShowSheet() {
            // Called when the material sheet's "show" animation starts.

        }

        @Override
        public void onSheetShown() {
            // Called when the material sheet's "show" animation ends.

        }

        @Override
        public void onHideSheet() {
            // Called when the material sheet's "hide" animation starts.
        }

        public void onSheetHidden() {
            // Called when the material sheet's "hide" animation ends.
        }
    });

Here is my Fab Class

public class Fab extends FloatingActionButton implements AnimatedFab {

public Fab(Context context) {
    super(context);
}


@Override
public void show() {
    show(0, 0);
}
@SuppressLint("RestrictedApi")
@Override
public void show(float translationX, float translationY) {

    setVisibility(View.VISIBLE);
}

/**
 * Hides the FAB.
 */
@SuppressLint("RestrictedApi")
@Override
public void hide() {

    setVisibility(View.INVISIBLE);
}

`
Here is my Log Cat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.teepe.teepe, PID: 29259
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.teepe.teepe/com.teepe.teepe.MainActivity}: java.lang.ClassCastException: android.support.design.widget.FloatingActionButton cannot be cast to com.teepe.teepe.Fab
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassCastException: android.support.design.widget.FloatingActionButton cannot be cast to com.teepe.teepe.Fab
at com.teepe.teepe.MainActivity.onCreate(MainActivity.java:95)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)

Animators may only be run on Looper threads

when hide sheet hideSheet(); get error:
FATAL EXCEPTION: cs-decoder Process: com.example.cexup_device, PID: 9091 android.util.AndroidRuntimeException: Animators may only be run on Looper threads at android.animation.ValueAnimator.start(ValueAnimator.java:1044)

APK signing -> Error: Expected resource of type anim [ResourceType]

Based on the sample app, I created my own Fab implementing AnimatedFab, and when generating a signed apk, Gradle returns me this error:

Error:(126) Error: Expected resource of type anim [ResourceType]

This is happening when providing the interpolator:

private Interpolator getInterpolator() {
return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator);
}

I fixed it temporarily by using new AccelerateDecelerateInterpolator() because I had to release my app. But this shouldn't be hard to fix :)

menu width

I'm using your library in a fragment. (Layout included below).

I'm using the same Fab implementation as you're using in the example. Only difference is I changed the width of the CardView to match parent, it should take up the whole width of the screen. But it doesn't. It takes a very small portion in the right corner of the screen. And I cannot identify where the problem originates from.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <be.prontopoc.ui.Fab
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:src="@drawable/ic_add_white"
        android:layout_margin="@dimen/fab_margin"/>

    <!-- Overlay that dims the screen -->
    <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
        android:id="@+id/overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Circular reveal container for the sheet -->
    <io.codetail.widget.RevealLinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="end|bottom"
        android:orientation="vertical">

        <!-- Sheet that contains your items -->
        <android.support.v7.widget.CardView
            android:id="@+id/fab_sheet"
            android:layout_width="match_parent"
            android:layout_height="200dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

            </LinearLayout>

        </android.support.v7.widget.CardView>
    </io.codetail.widget.RevealLinearLayout>

</android.support.design.widget.CoordinatorLayout>

First time not show sheet

When click first time after on fab after app start the sheet is not showing but second time i click then sheet showing. what is the problem i dont understand ....plz help me

CardView doesn't have a margin on < 5.0 Lollipop

Hi, There isn't any margin on devices without lollipop in the CardView.
I read in a previous issue that the margin is 16dp and I can see that on my nexus 6 running 5.1.1 but on a samsung galaxy s running 4.4.4 then there is no margin.

Issue: can't import

After trying to import and updating all things, I still get this error:

Gradle 'material-sheet-fab' project refresh failed
Error:No service of type Factory available in ProjectScopeServices.

How come?

Apk crashing below 5.0

App is crashing below 5.0 and when I include CircularReveal (as per the instructions), I am not able to build the apk only. I have raised issue with CircularReveal library also. Request you to please help me out in case if there is some workaround.

link - ozodrukh/CircularReveal#43

Memory Leak in MaterialSheetFab

The call:

// Set listener for when FAB view is laid out
        fab.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        // Initialize FAB anchor when the FAB view is laid out
                        if (!isFabLaidOut) {
                            updateFabAnchor();
                            isFabLaidOut = true;
                        }
                    }
                });

appears to leak the instance to this sheet (causing my activity to leak), since it's not removed from the OnGlobalLayoutListener.
This was caught using LeakCanary.

make sheet full screen

I want to make a full screen sheet. this is my layout file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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.support.design.widget.CoordinatorLayout
        android:id="@+id/eventdetail_coordinatorlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context="com.hhtv.eventqa.activity.EventDetailActivity">

        <android.support.design.widget.AppBarLayout
            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/eventdetail_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            <android.support.design.widget.TabLayout
                android:id="@+id/eventdetail_tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fillViewport="false"
                app:tabGravity="fill"
                app:tabIndicatorColor="@color/base_color_4"
                app:tabIndicatorHeight="@dimen/tablayout_indicator_height"
                app:tabMode="fixed" />
        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/eventdetail_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />


    </android.support.design.widget.CoordinatorLayout>
    <com.hhtv.eventqa.customView.CustomFAB
        android:id="@+id/eventdetail_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_comment" />

    <com.gordonwong.materialsheetfab.DimOverlayFrameLayout
        android:id="@+id/dim_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Circular reveal container for the sheet -->
    <io.codetail.widget.RevealLinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- Sheet that contains your items -->
        <android.support.v7.widget.CardView
            android:id="@+id/fab_sheet"
            android:layout_width="match_parent"
            android:layout_height="match_parent">


        </android.support.v7.widget.CardView>
    </io.codetail.widget.RevealLinearLayout>
</RelativeLayout>

and the custom FAB class is same as your sample, but this is the result:

http://i.imgur.com/Xd9toz6.gif

please tell me how did I do wrong and how to fix it
thanks

CardView radius style is not applied

Hi, and thanks for this library. Unfortunately I am not able to style the cardview in the material sheet. For instance, attributes such as cardCornerRadius or cardBackgroundColor don't have any effect, nor in my app nor trying to modify the sample app. Trying to achieve this via code doesn't work either. Have you noticed the same behaviour?

Fab is not shown after sheet is closed

I want to leave the sheet open after the device rotation, so if the sheet was open, then I manually call showSheet(). Sheet is shown as expected, but when I close it by pressing back key, the sheet is closed, but the fab does not appear. If I don't call showSheet(), the fab shows and works as usual.

Is this a bug or do I have to call something else for the fab to show after closing the sheet?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.