question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to have wrap_content height instead of fixed height?

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
andyleekpcommented, Apr 15, 2020

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>
0reactions
abdurahmanadiloviccommented, Feb 16, 2021

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anyway to keep the height of a layout as wrap content, but not ...
Use android:maxHeight to set the maximum height that you want the ScrollView to be. · I have set android:layout_height="wrap_content" and android ...
Read more >
ViewGroup.LayoutParams - Android Developers
This set of layout parameters defaults the width and the height of the children to ViewGroup. ... WRAP_CONTENT when they are not specified...
Read more >
ConstraintLayout does not measure height correctly when ...
ConstraintLayout does not measure height correctly when using wrap_content and layout_constrainedHeight is set to true. 7. Hotlists (2)
Read more >
wrap_content height not working as excpected | Android Forums
Hi Alex, · Thanks for your patience, · We have fixed the reported issue "SfAutoComplete and EditText heights are different when we set...
Read more >
How to make a SwiftUI view to fill its container width and height
1 Set .frame(maxWidth: .infinity) to make the text view expand to fill a container width. 2 Set blue border will make an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found