I've a layout with 2 SwipeRefreshLayout
and RecyclerView
, it works only if the layout_height
is fixed (ex: 200dp). If it is set to wrap_content
, the items are not visible.
I've tried a lot of solutions but it continues to not work. My layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="UselessParent">
<TextView
android:id="@+id/feedNews1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="@dimen/text_feed_rss_title_size" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="@+id/feedNews2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="@dimen/text_feed_rss_title_size" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" >
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/adsContainerNews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<com.google.android.gms.ads.AdView
android:id="@+id/adViewNews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
</LinearLayout>
</LinearLayout>
</ScrollView>
In this case, only first RecyclerView
is showed
My build:
compileSdkVersion 27
minSdkVersion 14
targetSdkVersion 27
implementation 'com.android.support:recyclerview-v7:27.1.1'
My code:
recyclerView1.setHasFixedSize(true);
recyclerView1.setNestedScrollingEnabled(false);
recyclerView2.setHasFixedSize(true);
recyclerView2.setNestedScrollingEnabled(false);
I've also tried with MyLinearLayoutManager
public class MyLinearLayoutManager extends android.support.v7.widget.LinearLayoutManager
but it does not work.
Is there a solution?
Thanks a lot