I have a ViewPager
in my application that act as a slider. My problem is I want to my view pager's size matches it's child size (the loaded image).
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/slider_viewpager"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
/>
<com.viewpagerindicator.CirclePageIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/slider_indicator"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="10dp"
/>
</RelativeLayout>
My page item :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slider_layout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:layout_alignParentBottom="true">
</ImageView>
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progressBar"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
wheel:matProg_barColor="@color/primaryColor"
wheel:matProg_progressIndeterminate="true" />
</RelativeLayout>
but with this layout my view pager height become 0 when the images loaded after some time from a url. How can I make my View pager gets It's size from It's child? (something like WRAP_CONTENT)
====
I changed LayoutParams
dynamically after received the BitMap
images but that doesn't worked and the result size become bigger that it supposed to be.Something like below :
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(bitmap.getMeasuredWidth(),bitmap.getMeasuredHeight());
image.setLayoutParams(params);
pager.setLayoutParams(params);