0

My problem is scrolling in ExpandableListView with coordinator layout design. Toolbar works right and When it touched up, it gets hide, but ExpandableListView doesnt scroll

I need to use NestedScrollView because the layout_navigation_view is Common everywhere.

Take a look at the

picture http://info-sys.persiangig.com/noScroll.gif

My main code with Java AND My design code with XML is:

ActivityMain.java

public class ActivityMain   extends ActivityNavigationView {

           ArrayList<StructNote> group ; //StructNote public String id,title,icon; // StructNote = Filde Parametr
           ArrayList<ArrayList<StructNote>> child ;

           ActivityAdapter mAdapter; // class extends BaseExpandableListAdapter 

           ExpandableListView exListView ;

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

        // ---> content_frame =>  layout_navigation_view.xml
        FrameLayout contentFrameLayout = (FrameLayout) findViewById(R.id.content_frame); 
        getLayoutInflater().inflate(R.layout.activity_main, contentFrameLayout);

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.getMenu().getItem(1).setChecked(true);

        exListView = (ExpandableListView) findViewById(R.id.exListView);

        //... Fill Group Child Adapter List
        //...Other CODE ...
    }
 }

ActivityNavigationView.java

public class ActivityNavigationView extends AppCompatActivity {

    DrawerLayout drawerLayout;
    ActionBarDrawerToggle actionBarDrawerToggle;
    Toolbar toolbar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_navigation_view);
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        //...Other CODE ... Click menu and Open close NavigationView, Toolbar
    }
 }

layout_navigation_view.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:fitsSystemWindows="true"
    tools:openDrawer="start">

        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/background_light"
            android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/main.appbar"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:layout_scrollFlags="scroll|enterAlways">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/main.collapsing"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginStart="48dp"
                app:expandedTitleMarginEnd="64dp">

            <ImageView
                android:id="@+id/main.backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:fitsSystemWindows="true"
                android:src="@drawable/bg_tool_bar"
                app:layout_collapseMode="parallax"/>

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:popupTheme="@style/AppTheme.PopupOverlay"
                    app:layout_collapseMode="pin">
                </android.support.v7.widget.Toolbar>
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>


        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

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


            <android.support.design.widget.FloatingActionButton
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_margin="@dimen/activity_horizontal_margin"
                android:src="@android:drawable/ic_dialog_info"
                app:layout_anchor="@id/main.appbar"
                app:layout_anchorGravity="bottom|right|end" />

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


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_activity_main"
        app:menu="@menu/activity_main_drawer" />

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

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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"
    android:orientation="vertical">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeToRefresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

            <ExpandableListView
                android:id="@+id/exListView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:transcriptMode="disabled"
                android:divider="@null"
                android:dividerHeight="0dp"
                android:minHeight="130dp">
            </ExpandableListView>

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

</LinearLayout>

enter image description here

Edit :

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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"
    android:orientation="vertical">


            <ExpandableListView
                android:id="@+id/exListView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:transcriptMode="disabled"
                android:divider="@null"
                android:dividerHeight="0dp"
                android:minHeight="130dp">
            </ExpandableListView>

</LinearLayout>
omid
  • 21
  • 5

1 Answers1

0

Toolbar works right and When it touched up, it gets hide, but ExpandableListView doesnt scroll

Yes it's because of SwipeRefreshLayout and using SwipeRefreshLayout inside of NestedScrollView.

Add the SwipeRefreshLayout Widget To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView

Solution:

Place SwipeRefreshLayout outside of NestedScrollView in layout_navigation_view.xml first:

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

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        ...
    </android.support.v4.widget.NestedScrollView>

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

And remove SwipeRefreshLayout in activity_main.xml.

ʍѳђઽ૯ท
  • 15,369
  • 7
  • 47
  • 103
  • 1
    yes i know and that is right for ListvVew, GrideView and RecyclerView **but** it doesnt work for ExpandableListView and i need to scroll **ExpandableListView ** – omid Sep 07 '18 at 13:29
  • 1
    `public class ExpandableListView extends ListView ` **It extends from ListView** and since you have added `SwipeRefreshLayout` inside of `NestedScrollView` this causes issue. And [`SwipeRefreshLayout`](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout) is not what you need for scrolling. – ʍѳђઽ૯ท Sep 07 '18 at 13:36
  • 1
    "SwipeRefreshLayout" isnt important it doesnt cause issue – omid Sep 07 '18 at 13:44
  • 1
    Oh, i missed this one. Try this: https://stackoverflow.com/a/37605908/4409113 It's because of (`ExpandableListView` & `NestedScrollView`) both are scrollable. – ʍѳђઽ૯ท Sep 07 '18 at 13:51