gowong / material-sheet-fab Goto Github PK
View Code? Open in Web Editor NEWAndroid library that provides the floating action button to sheet transition from Google's Material Design.
License: MIT License
Android library that provides the floating action button to sheet transition from Google's Material Design.
License: MIT License
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.
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'
}
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>
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 ??
How do I get this to work in NativeScript?
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
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>
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)
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?
When I click the FAB, it morphs into the sheet. I can click somewhere in the sheet, hold, and drag down to begin scrolling my CoordinatorLayout/NestedScrollView in the background. If I do any such sort of scrolling, when I dismiss the sheet, the FAB is put in a buggy location with a buggy size.
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.
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)
When setting the corner radius of CardView
, drawing glitches can be observed.
The drawing of bottom round corners is delayed by ~1 second.
Can be easily replicated with the sample app.
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)
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
hello. are there some library in swift? THanks
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)
in your sample app
how to hide and show fab when recyclerView scrolls up and down?
thanks
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. ๐
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.
Steps to reproduce in the sample:
Right now I'm only able to set rounded button which is the default and I want to switch to the rounded rectangle with some left drawable and some text in right.
Thanks for the amazing library.
Great lib, but...
On Lollipop and higher all is going smooth and nice, on API 19 and lower fab going higher. Everything was made due to example. Stacked on it, help plz.
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 reproduce:
Just change the width of the CardView to match_parent in the sample
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
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.
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.
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)
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?
Error:No service of type Factory available in ProjectScopeServices.
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?
How to hide the sheet without animation/transformation?
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.
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
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?
when I touch outside the sheet, it hides the sheet!
how to hidesheet(); just forexample by a sheetItem click?
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 :)
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.
FAB is shifted to the left after many clicks on it. Steps to reproduce in the sample 1.0.3:
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
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)
To show how it's best to transition between different FABs ...
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'.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.