Questions tagged [android-wrap-content]

In Android, "wrap content" will wrap the view's size so that it will be just big enough to enclose its content. Use this tag for issues related to this layout param (whether on XML Layout or programmatically)

There are 3 possible values when deciding the size of a view:

  • Wrap content (XML: wrap_content, code: WRAP_CONTENT)
  • Match parent (XML: match_parent, code: MATCH_PARENT)
  • Exact number

"Wrap content" will wrap the view's size so that it will be just big enough to enclose its content.

wrap content vs match parent

Demonstration on Suragch's answer for the difference between "wrap content" and "match parent"


See also:

105 questions
2
votes
2 answers

View Pager wrap content issue

I m trying to set view pager height to wrap_content using this Android: I am unable to have ViewPager WRAP_CONTENT But it's leaving extra white space at the bottom How do I remove this space? This is my xml code:
Karthik K M
  • 619
  • 2
  • 9
  • 24
2
votes
2 answers

How to set dimensions of a DraweeView to "wrap_content" in the Fresco library

I'm using the Fresco library in my app to load images. The problem is that I can't set my images height to "wrap_content" because "wrap_content" is not supported in the Fresco library. So how can I make my images to look good using a DraweeView? I…
Itiel Maimon
  • 834
  • 2
  • 9
  • 26
2
votes
0 answers

Make Custom View to Wrap_content

I am using library OnBarCodeGenerate for android. This draws barcode in a Custom View. How should i write my custom View's onMeasure method in a way that it takes as much as space it requires. The same behaviour as wrap_content for both height and…
2
votes
2 answers

MVVMCross Nested Recyclerview Out of Memory Issue

I have tried to create nested recyclerview in combination with the mvvmcross-framework which actually worked quite easily, but now I'm getting out of memory exceptions. Scenario I have a list of around 3000 entries with complex and long names, which…
2
votes
3 answers

Android Horizontal RecyclerView wrap_content

hello I'm trying to use Recyclerview, below code results only a blank screen, can you please tell me where I'm going wrong
Manish
  • 1,246
  • 3
  • 14
  • 26
1
vote
1 answer

How to make two CardView height as wrap_content in a linear layout

I have two MaterialCardView in a linear or relative layout (i don't care about the parent layout I only want the result) I want that both of the MaterialCardView should have wrap_content height Right now The 1st MaterialCardView contains a…
1
vote
1 answer

Wrap content around text in TextField

i'm trying to make a TextField that is a minimum size, and that expands around the text being written inside it, how can i achieve this? This is my test code var text by rememberSaveable { mutableStateOf("Prova") } Row( modifier =…
1
vote
0 answers

Android - TextView wrap_content not working when number text

My device has not set a custom font, so the font of the app is supposed to follow the device setting font. When applying custom font, the width of the textview was found to be cut, so I left it as wrap_content, but it didn't work properly. (Default…
1
vote
0 answers

Having trouble with TextView in ConstraintLayout, neither *match constraint* nor *wrap_content* give desirable result

I have a TextView. I really can't get why wrap_content doesn't work, or sometimes match constraint does the trick whereas the issue is about wrapping. In this case, I can't make the message appear in my screen. I don't mind if it's a singleline or…
1
vote
1 answer

SwipeRefreshLayout wrap_content not working with ListView in Dialogfragment

I'm trying to set SwipeRefreshLayout which contains children ListView to wrap_content in a DialogFragment. to actually make the Dialog wrap the height of it's childrens, because it's always filling the window height even if the ListView has only one…
1
vote
1 answer

ScrollView and its content use 'wrap_content'. How to assign constraint priority?

I need a horizontal ScrollView with a fixed height of 100dp and dynamic content of ImageViews. Currently I the ScrollView has a horizontal LinearLayout with ImageViews. The ImageViews have wrap_content enabled for their width, while the height is on…
1
vote
2 answers

Why does my text get cut out as soon as it hits multiple lines?

I have a simple RecyclerView using 2 strings. As soon as the 2nd TextView gets multiple lines of text, it gets cut out instead of just expanding the height of the view. For example the text that two textViews received was: "Director":"Cate…
aratata
  • 1,147
  • 1
  • 6
  • 22
1
vote
2 answers

What does it mean layout_width/heigth = wrap_content in progress bar and swith

i can't understand the value wrap_content for View's elements (like ProgressBar, Switch, primitive View with background - that for some reason takes all the available place on screen), it isn't trivial such as TextView that wrap_content means "be as…
Eitanos30
  • 1,331
  • 11
  • 19
1
vote
1 answer

Leanback VerticalGridView height: wrap_content

I have a VerticalGridView in which i plan to use multiple VerticalGridViews. Wrap_Content does nothing for a VerticalGridView if its set on it's height, The GridLayoutManager simply ignores it if the view is in a normal view, and it does…
1
vote
1 answer

I use Glide and RecyclerView together but it doesn't scroll as I want

I am using RecyclerView ('androidx.recyclerview:recyclerview:1.1.0') and Glide('com.github.bumptech.glide:glide:4.10.0'). I wanted to create image list with RecyclerView. And each view holder load an image by Glide. After loading all images, I want…