0

I have implemented sliding up panel provided by Umano library in my android application. I have used my drawer layout inside the sliding up panel like this

xml

<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:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <include
        android:id="@+id/toolbar_actionbar"
        layout="@layout/toolbar_default"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/fmYellow" />


    <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar_actionbar"
        android:gravity="bottom"
        sothree:umanoPanelHeight="60dp"
        sothree:umanoShadowHeight="4dp">


        <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <FrameLayout
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clickable="true" />

            <!-- android:layout_marginTop="?android:attr/actionBarSize"-->
            <fragment
                android:id="@+id/fragment_drawer"
                android:name="com.fm.etunes.phone.view.NavigationDrawerFragment"
                android:layout_width="@dimen/navigation_drawer_width"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                app:layout="@layout/fragment_navigation_drawer"
                tools:layout="@layout/fragment_navigation_drawer" />

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


        <LinearLayout
            android:id="@+id/blurbackground"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#464646"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/bottomBar"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal">

                <ImageView
                    android:id="@+id/song_image"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher1" />


                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/song_title"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:text="Etunes"
                        android:textColor="@color/player_footer_text_color"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/artist_name"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:textSize="13dp"
                        android:text="Etunes"
                        android:singleLine="true"
                        android:textColor="@color/player_footer_text_color" />

                </LinearLayout>
     </com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>

It works perfectly like it's supposed to. But the problem i have is i want to close the sliding up panel when the drawer is open.I have used this code but could not get it to work. How can i close the sliding up panel when the drawer is open.

code

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (!mNavigationDrawerFragment.isDrawerOpen()) {


            // Only show items in the action bar relevant to this screen
            // if the drawer is not showing. Otherwise, let the drawer
            // decide what to show in the action bar.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;

        } else {

            Toast.makeText(activity,"drawer open",Toast.LENGTH_LONG).show();
            slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);

        }
        return super.onCreateOptionsMenu(menu);
    }

PS: i get the toast saying drawer is opening.But it seems

slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);

is not working.

CraZyDroiD
  • 6,622
  • 30
  • 95
  • 182

1 Answers1

0

Have you ever seen it collapsed? Try to channge the DrawerLayout and SlidingUpPanel's places, i.e., put the second one into the first.

khusrav
  • 5,267
  • 5
  • 27
  • 38