Android-Image-Slider
Android-Image-Slider copied to clipboard
How to have wrap_content height instead of fixed height?
I have used wrap_content height. But it doesn't show the image. I want to use the wrap_content height, so that the slider is shown based on image retrieved image size from url.
Did you find any solution?
Any Solution to this?
@i-m-aman @yilmaz-gokhan I've used with fixed ratio and serving the images in that fixed ratio, where I control the source.
Using ConstraintLayout as a parent view to control the ratio:
Here is the xml example:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.smarteist.autoimageslider.SliderLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="H,2:1" //2=ratio of height, 1=ratio of width
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
I like your answer @andyleekp, the only thing that can be improved, if needed, is to calculate the aspect ratio dynamically for each image (if images are what drives heights for each page of the slider).