0

Я реализую приложение с ExpandableListview, Fragment, Viewpager и CollapsingToolbarLayout.ExpandableListView не работает должным образом

Но у меня есть проблема. У моего ExpandableListview есть неправильное поведение. Остальные пункты ниже разрезаны. И когда я нажимаю на элемент ниже верхнего элемента, отображаемого за TabLayout.

Какая у меня ошибка в коде? Спасибо

main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:fitsSystemWindows="true" 
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" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:expandedTitleMarginStart="30dp" 
     app:expandedTitleMarginEnd="25dp" 
     app:expandedTitleTextAppearance="@style/HeaderTitleStyle" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/background" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:fitsSystemWindows="true" 
      app:layout_collapseMode="parallax" 
      android:src="@drawable/img_oficinas"/> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:minHeight="?attr/actionBarSize" 
      android:background="@android:color/transparent" 
      app:theme="@style/ToolbarColoredBackArrow" 
      app:layout_collapseMode="pin"/> 

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

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:background="@color/colorAccent" 
     app:tabTextColor="@color/tabs_text_selector" 
     app:tabIndicatorHeight="3dp" 
     app:tabIndicatorColor="@android:color/white"/> 

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

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

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

fragment.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fillViewport="true"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <ExpandableListView 
     android:id="@+id/expandableListView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:groupIndicator="@null" 
     android:background="@android:color/white" 
     android:dividerHeight="0dp" 
     android:divider="@android:color/white" /> 

</LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
+0

какой тип ошибки вы получаете ?? – Madhur

+0

@Madhur Элементы ниже отрезаны, а элементы выше отображаются за Tablayout, когда нижние нажаты. – IMS

+0

установить фиксированную высоту и ширину – Madhur

ответ

0

CoordinatorLayout «s ScrollingViewBehavior работает только с видами, которые поддерживают вложенные прокрутки (Exp RecyclerView). ExpandableListView не поддерживает его по умолчанию, поэтому CoordinatorLayout не обрабатывает положение ExpandableListView правильно.

Для API> 21 вы можете получить это поведение:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
    setNestedScrollingEnabled(true); 
} 

В противном случае вы можете перейти к пользовательской RecyclerView или ExpandableRecyclerView.

Смежные вопросы