I am using a nestedscrollview as I have recyclerview and other views in the same Activity. I even need to add a view pager in the same activity in between a list and a view. I see that view pager is not occupying any space if I put the height as wrap_content. It shows up if I hard code the height. I need the viewpager to be wrapped as the content in the pager may increase or decrease.
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.neighboure.customer.activity.ProductDetailActivity"
tools:showIn="@layout/activity_product_detail">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/_10sdp">
<android.support.v7.widget.RecyclerView
android:id="@+id/productsimgrecycleview"
android:layout_width="match_parent"
android:layout_height="@dimen/_60sdp">
</android.support.v7.widget.RecyclerView>
<android.support.v4.view.ViewPager
android:id="@+id/des_spec_container"
android:layout_width="match_parent"
android:layout_height="180dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btncart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/lightgrey"
android:text="@string/label_add_to_cart"
android:textColor="@color/black"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
Please find the below screenshots for reference
As you can see in the above picture the content in viewpager is visile as I have hard coded the height of the view pager.
In the above picture, I have wrapped the viewpager and the content is not visible.
Thanks in advance.