shiburagi / Drawer-Behavior

Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.
https://shiburagi.github.io/Drawer-Behavior/
MIT License
593 stars 101 forks source link

Issue in Android veriosn 4.4.2 #14

Closed Amr-Elmadah closed 5 years ago

Amr-Elmadah commented 5 years ago

When just try to use isDrawerOpen(int Gravity) it works fine when I test it on android oreo but the app crashes on android version 4.4.2 Here's the crash : java.lang.IllegalArgumentException: View android.widget.FrameLayout{a5fc4610 V.E..... ........ 0,0-1440,2304} is not a drawer at android.support.v4.widget.DrawerLayout.isDrawerOpen(DrawerLayout.java:1820) at android.support.v4.widget.DrawerLayout.isDrawerOpen(DrawerLayout.java:1838)

shiburagi commented 5 years ago

Okay, will check it

shiburagi commented 5 years ago

May I know you minSdkVersion & targetSdkVersion?

shiburagi commented 5 years ago

Try use this version,

implementation 'com.infideap.drawerbehavior:drawer-behavior:0.1.1'

Amr-Elmadah commented 5 years ago

May I know you minSdkVersion & targetSdkVersion? minSdkVersion 19 targetSdkVersion 28

shiburagi commented 5 years ago

May I know you minSdkVersion & targetSdkVersion? minSdkVersion 19 targetSdkVersion 28

I run on emulator using Kitkat(4.4) android version, and it works fine. Did u already try running using this version,

implementation 'com.infideap.drawerbehavior:drawer-behavior:0.1.1'

Amr-Elmadah commented 5 years ago

May I know you minSdkVersion & targetSdkVersion? minSdkVersion 19 targetSdkVersion 28

I run on emulator using Kitkat(4.4) android version, and it works fine. Did u already try running using this version,

implementation 'com.infideap.drawerbehavior:drawer-behavior:0.1.1'

Actually I don't import the library as all, I just take a copy of the AdvanceDrawerLayout file and just add custom modification on it to just force it to be on right side in all localizations here's the modification which I did on that file, just this method

int getDrawerViewAbsoluteGravity(int gravity) { return GravityCompat.getAbsoluteGravity(Gravity.RIGHT, ViewCompat.getLayoutDirection(this)) & Gravity.HORIZONTAL_GRAVITY_MASK; } I just ignored using the passed parameter and use Gravity.Right

shiburagi commented 5 years ago

May I know you minSdkVersion & targetSdkVersion? minSdkVersion 19 targetSdkVersion 28

I run on emulator using Kitkat(4.4) android version, and it works fine. Did u already try running using this version, implementation 'com.infideap.drawerbehavior:drawer-behavior:0.1.1'

Actually I don't import the library as all, I just take a copy of the AdvanceDrawerLayout file and just add custom modification on it to just force it to be on right side in all localizations here's the modification which I did on that file, just this method

int getDrawerViewAbsoluteGravity(int gravity) { return GravityCompat.getAbsoluteGravity(Gravity.RIGHT, ViewCompat.getLayoutDirection(this)) & Gravity.HORIZONTAL_GRAVITY_MASK; } I just ignored using the passed parameter and use Gravity.Right

i see. how about your layout, how u define it? It think, this problem because it cannot find the drawer

shiburagi commented 5 years ago

if u want to make it always on the right side, u can set the android:layout_gravity="end"

<android.support.design.widget.NavigationView
       ...
        android:layout_gravity="end"
        .../>
Amr-Elmadah commented 5 years ago

Here's the layout of the drawer <myPackageName.AdvanceDrawerLayout 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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPrimary" android:fitsSystemWindows="false" android:layout_gravity="right" tools:openDrawer="right">

</myPackageName.AdvanceDrawerLayout>

and as you know AdvanceDrawerLayout extends DrawerLayout (it's your class) it works fine from 5.1, minSdk 22

Amr-Elmadah commented 5 years ago

Here's the layout

<MyPackageName.AdvanceDrawerLayout 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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPrimary" android:fitsSystemWindows="false" android:layout_gravity="right" tools:openDrawer="right">

<LinearLayout
    android:id="@+id/ll_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/mainBg"
    android:orientation="vertical">

    <include layout="@layout/layout_header" />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <include layout="@layout/layout_footer" />

</LinearLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="right"
    android:fitsSystemWindows="false"
    android:foregroundGravity="center_horizontal"
    android:maxWidth="@dimen/_160sdp">

    <include layout="@layout/layout_side_menu" />
</android.support.design.widget.NavigationView>

</MyPackageName.AdvanceDrawerLayout>

Amr-Elmadah commented 5 years ago

if u want to make it always on the right side, u can set the android:layout_gravity="end"

<android.support.design.widget.NavigationView
       ...
        android:layout_gravity="end"
        .../>

Yes but my app supports Arabic so I must put it right not end

shiburagi commented 5 years ago

I just update the AdvanceDrawerLayout code to support RTL,

and u can refer the sample code here,

https://github.com/shiburagi/Drawer-Behavior/blob/master/app/src/main/java/com/infideap/drawerbehaviorexample/drawer/AdvanceDrawer6Activity.java

Amr-Elmadah commented 5 years ago

I know that you support RTL but I just want to force it to be show on right even the app is localized "ar" or "en"

shiburagi commented 5 years ago

i think u need manually check at onCreate(), something like this

if(getWindow().getDecorView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL){
    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) navigationView.getLayoutParams();
    params.gravity = Gravity.START;

}else{
    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) navigationView.getLayoutParams();
    params.gravity = Gravity.END;
}
Amr-Elmadah commented 5 years ago

I'll give it a try and get back to you, thanks.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.