How To Make Swiperefreshlayout Wrap_content?
How to make SwipeRefreshLayout wrap_content? Here is my layout mydialog_fragmet.xml:
Solution 1:
The solution for this specific behavior is to wrap the view in a parent layout, using a specific dp is only recommended if you want it on that size
<LinearLayoutxmlns: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:background="@color/appBackgroundColorLight"android:orientation="vertical"><android.support.v4.widget.SwipeRefreshLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><LinearLayoutandroid:id="@+id/contentLayout"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@color/appBackgroundColorLight"android:orientation="vertical"
><android.support.v7.widget.RecyclerViewandroid:id="@+id/recyclerView"android:layout_width="match_parent"android:layout_height="wrap_content"android:clipToPadding="false"android:paddingTop="16dp"android:scrollbarSize="2dp"android:scrollbarStyle="outsideOverlay"android:scrollbarThumbVertical="@color/colorAccent"
/><includelayout="@layout/view_add_place_button"/></LinearLayout></android.support.v4.widget.SwipeRefreshLayout>
Solution 2:
Found solution:
<LinearLayoutxmlns: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:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"
><com.example.views.MaxHeightSwipeRefreshLayoutandroid:id="@+id/swipeRefreshLayout"android:layout_width="match_parent"android:layout_height="wrap_content"app:maxHeight="382dp">//size 382 = 300(RecyclerView) + 82 (addButton)
<com.example.views.MaxHeightNestedScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"app:maxHeight="382dp"><LinearLayoutxmlns: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="wrap_content"android:background="@color/appBackgroundColorLight"android:orientation="vertical"tools:background="@color/appBlue"
><com.example.views.MaxHeightRecyclerViewandroid:id="@+id/placesRecyclerView"android:layout_width="match_parent"android:layout_height="wrap_content"android:clipToPadding="false"android:paddingTop="16dp"android:scrollbarSize="2dp"app:maxHeight="300dp"android:scrollbarStyle="outsideOverlay"android:scrollbarThumbVertical="@color/colorAccent"
/><includelayout="@layout/view_add_place_button"/></LinearLayout></com.example.views.MaxHeightNestedScrollView></com.example.views.MaxHeightSwipeRefreshLayout></LinearLayout>
Where MaxHeight*
view is from https://stackoverflow.com/a/48728490/2425851
Post a Comment for "How To Make Swiperefreshlayout Wrap_content?"