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
0
votes
1 answer

How to wrap dialog to its content?

I want to show a dialog with a message and some buttons at the bottom of the dialog. I intent to add more controls to dialog so I use a custom view. Here is the code: My hv_popup.xml:
NoName
  • 7,940
  • 13
  • 56
  • 108
0
votes
1 answer

Android adding text to textview dynamically in Fragment (wrap_content)

I have a problem with adding text to TextView which is placed in horizontal LinearLayout in Fragment. After adding some text the view always shows only 1 line. TextView height is not wrapping to its content. My xml file:
0
votes
0 answers

AppBarLayout wrap_content does not work on API24 devices

I have an Appbarlayout like this in my app:
breakline
  • 5,776
  • 8
  • 45
  • 84
0
votes
2 answers

Why wrap_content has no effect?

Set wrap_content in RecycleView holder:
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
3 answers

How to use "full" of wrap_content, created by other views

Currently im working on a fine ui. Now i came to this: Im stucking on the "profile_layout" on the left side with the muffin inside. For the two bars on the right side im using wrap_content. But now im stucking to let the profile_layout use the…
user4546546
0
votes
2 answers

TextView doesn't wrap text

I need dynamically create next xml:
Stan Malcolm
  • 2,740
  • 5
  • 32
  • 53
0
votes
2 answers

Android list view setOnItemClickListener works only if

I have an Android layout. I've set a listener like list.setOnItemClickListener. Everything seems to work fine. In the line below: If I change…
Hélène
  • 377
  • 1
  • 5
  • 13
0
votes
1 answer

Why does textview with weight have invalid height in case of text wrapping?

I have a dialog, which has a layout xml. Controls are vertically aligned, and in one "row" there is a textview and a seekbar. Textview has weight=1, and seekbar has weight=2. Now the problem is that if textview cannot fit, it is wrapped, but the…
Zoli
  • 841
  • 8
  • 31
0
votes
1 answer

How to wrap a complete line and not just words?

I am currently writing an App for Android and in one of the layouts I have a users name and beside it a couple of tags. If both the users name and the tags are short enough, they fit neatly into one line. However, when either of the two are longer I…
The Salt
  • 336
  • 5
  • 10
0
votes
1 answer

Modify weight in the code doesn't display anything

I'm trying to create with code, 3 linearlayout with weight. Put them in a linearlayout, and put this last in a RelativeLayout. At the end I use this RelativeLayout in a Spinner (I say this in case is relevant). The problem is when I try to put the…
jCastellote
  • 79
  • 1
  • 3
0
votes
3 answers

Why is TextView wrapping when gravity is set to left?

I'm having an issue where my textview is wrapping a word when the gravity is set to left. I want it to just display the word without any wrapping. A visual of what I want: Currency Balance Held Value But this is what I'm getting: C …
Seslyn
  • 807
  • 10
  • 19
-1
votes
2 answers

Android - Button within nested LinearLayout doesn't show

I am trying to create a vertical Linear Layout in which every row is a horizontal Linear Layout with 2 buttons (as you can see in the picture below). The height of both buttons should be determined by the content of the left one ("EXERCISE"), and…
-1
votes
1 answer

Allow usage of values like ‘wrap_content’ in attrs.xml

How can I allow usage of values like wrap_content or match_parent in attrs.xml resource file on Android? My attrs.xml. I want the foo_dimen…
-1
votes
1 answer

Android Layouts -"wrap_content" is not allowing elements to the right to be displayed if the content width is too wide

This piece I am working on has a design requirement to show on one row some text, followed by an image. The image should always be aligned next to the text like this: [Some Text] [Img] [Some longer Text] [Img] For this, I'm using the "wrap_content"…
-1
votes
3 answers

How can use wrap-content for Relative Layout Without fill Parent

Sorry for my bad English, I set RelativeLayout width wrap_content, but it fill_parent. here is my code:
1 2 3 4 5 6
7