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
0 answers

Increase height of TextView from bottom to top when text goes to new line

Basically, the height of TextView increases to the bottom whenever the text goes to a new line. But I want TextView height increase to the top. Normally this is what happens when text size increases and goes to the new line And this is what I need…
Anil Bhomi
  • 691
  • 7
  • 12
0
votes
0 answers

TextView overrides other views with ConstraintView

I have been trying to create a simple textView (we'll call it "Body") with some little text below - we'll call it ("More"). My plan is to have the "Body" TextView taking as much as it requires, and just below - is the "More" text view. I…
0
votes
2 answers

Android Layout: How to ellipsize TextView depending on surrounding textviews?

I need your help designing a layout that works with the few following requirements: Requirements: TextA (Green): is always there. may vary in length (1 to 50 chars). is the only one which must be ellipsized when content is too long for the…
0
votes
1 answer

get button size after wrap_content?

how to get button size, after taking into consideration wrap_content attribute? I want to create 2 buttons of equal sizes, both of them with wrap_content attribute, so my solution was to create them both with wrap_content, get the maximum width and…
0
votes
1 answer

Limited WRAP_CONTENT for edittext

I want that when my edittext is empty it's height is 40px, i.e., it takes space of only one line. And when text is typed the height increases. It should function more like the WRAP_CONTENT on its height, but I want that once it reaches the height of…
0
votes
1 answer

RecyclerView wrap_content not working on API 23 and above

I have a layout with a RecyclerView inside a LinearLayout which is also inside a custom NestedScrollView. In api 21 and 22 the layout looks like it's supposed to showing all the elements of the RecyclerView, but in api 23 and above only one or two…
0
votes
2 answers

How can I adjust the size deppending on the visible content in an android view?

I'm creating a list view in an android app and each item expands and collapses. Here is each item's code:
0
votes
1 answer

How to do wrap content on half circle custom view?

I'm making half circle custom view on Android. However, I'm struggling to remove the un-needed bottom white space on wrap content. I think because it is drawing based on 'a full circle' calculation. I'm sharing my Custom View implementation, as well…
0
votes
2 answers

Second Activity is blank

The second activity has a ListView and it does not display it. The Log.i in the UserList shows that the activity is active. MainActivity.java: public void makeUserListIntent() { Intent userListIntent = new …
0
votes
3 answers

Android height wrap_content with fix ratio

My XML file has a LinearLayout containing two ListView with android:height="wrap_content". However, when one of the ListView has too much contents, it pushes another ListView and eat up its space. What can I do to make it stops pushing at certain…
0
votes
2 answers

Listview inside scrollview does not scroll in lanscape mode

I have to generate a dynamic listview in android. The listview is put inside a scrollview because I have other content too to display above the listview. Something like this : Down part is the listview which is dynamically added. This all comes…
Arti
  • 2,993
  • 11
  • 68
  • 121
0
votes
1 answer

What are the default values of wrap_content

I know slightly strange, but when we put wrap_content as a value for our layouts, what are the default values? Such as, I create a button with W and H both set to wrap_content. I'm aware it will change accordingly to the text inside, but when it's…
user8494778
0
votes
3 answers

Cannot show all the content using wrap_content in Android

Can anyone explain to me why I can't show the content of address using the following XML code. Thank you so much in advance. The content should be more than 3 lines, but only two lines of content are showed when I execute the program.
Michael
  • 183
  • 2
  • 10
0
votes
1 answer

setting height to wrap_content in Java makes the view deny all predefined XML attributes?

I have created a TextView in XML and have set some rules for it (for example layout_bellow="something"), and made it's height set to 0, so that when a button is clicked, it's height would be set to wrap_content. I wrote the code bellow for the…
MrChips
  • 11
  • 2
  • 6