Questions tagged [fill-parent]

FILL_PARENT (renamed MATCH_PARENT starting Android API Level 8), is a constant describing that a view would like to be as big as its parent (minus any padding).

FILL_PARENT (renamed MATCH_PARENT starting Android API Level 8), is a constant describing that a view would like to be as big as its parent (minus padding). It can be used for both width and height. It is the opposite of WRAP_CONTENT, which indicates that the view wants to be just big enough to enclose its content (plus padding).

Both constants are part of the ViewGroup.LayoutParams class, from which all other LayoutParams derive, and aid in ensuring that Android applications can display properly across a variety of device screen sizes and densities. The equivalents in XML share the same names, but all lowercase.

The sample below describes a LinearLayout that vertically stacks a TextView and Button. The LinearLayout requests to be sized as big as its parent by means of android:layout_width="match_parent" and android:layout_height="match_parent". The two child views, however, are requested to limit their width and height to their contents using the wrap_content values.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello, I am a TextView" />
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello, I am a Button" />
</LinearLayout>
73 questions
0
votes
3 answers

fill_parent not stretching background image

I am going crazy here. I swear I've had this work a thousand times before and it's like nothing is behaving correctly now. I have to be doing something stupid. A few days ago I was having issues with the background on a list view item not filling…
honeal
  • 1,459
  • 1
  • 18
  • 19
0
votes
1 answer

Android: Same xml acts differently depending on where I inflate it and I don't know why

Why do some views in a linearlayout within a scrollview fill the parent when fill_parent is set when inflated from xml directly but don't when added via a custom component that inflates the same xml? The result of inflating the same xml in two…
0
votes
2 answers

How to draw elements from the right to the left?

I want to have a button at the rigth of the screen, and an edittext which take all the place it can take at the left of the button. How can I do? This xml print me the button at the left of the screen but nothing before :/
Imotep
  • 2,006
  • 2
  • 25
  • 38
0
votes
2 answers

FrameLayout/WebView ignores fill_parent in dialog theme

I have an Activity with the dialog theme. That Activity uses the following xml layout:
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
0
votes
1 answer

Set a Width and Height to Fill Parent Android SlideShow

i want to make a SlideShow to show the image in full screen but the code i got was using a absolute size, i need to change it to fill_parent but i can't. here is the code, public class SlideShow extends View { public final int…
0
votes
4 answers

Android match parent leaving a right gap

As you can see in the screenshot below there is a small gap on the righthand side where the table rows are not matching parent. It is best viewed in the divider, but everything is not fully matching parent. I am at my wits end with this. Any help…
KisnardOnline
  • 653
  • 4
  • 16
  • 42
0
votes
1 answer

Find/Replace broke my application (reckless mistake)

Out of patience I did one of the things that you're not supposed to do unless you are ABSOLUTELY SURE. I wasn't absolutely sure and now I'm paying for it. What Happened My outdated app is using fill_parent as an attribute for android:layout_height.…
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
0
votes
0 answers

Expandablelistview layout not fill parent

I have an expandablelistview with 3 levels. Here my layout files: activity_main.xml
F.M.
  • 243
  • 2
  • 8
  • 23
0
votes
4 answers

Why does image in relative layout with "fill_parent" hide button underneath?

I'm trying to increase the size of an image in relative layout. Right now, its width and height are set to wrap_content. When I set them fill_parent, the image grows, but pushes the button underneath off the display. The relevant XML is below. What…
Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213
0
votes
1 answer

(Android Studio) App Background Image Doesn't Fill Screen

I'm new to app programming and require some assistance. I am building a simple app on Android Studio, but my app's background image (I named it "green_background") doesn't entirely fill the screen. I can't provide a screenshot because I don't have…
0
votes
1 answer

How to make the width of a grid view 100% across the screen

I have a grid view inside my layout and I am trying to make it stretch all the way across the screen. My XML for this gridview follows below.
Rehaan Ahmad
  • 794
  • 8
  • 23
0
votes
3 answers

relative layout not fitting the entire screen

the green coloured background is the relative layout under device, its not fitting the entire screen (there is a white space in between )even though i have made the layout to be fill_parent or match_parent. here is the xml code of my app …
0
votes
1 answer

Android Imageview distorted when viewing on landscape large devices

I am currently trying to show an image using imageview, this image just has the certain height but it should fill the entire width of the screen. On portrait mode it and landscape mode on a mobile phone(Samsung galaxy note 2) it shows just fine but…
marchemike
  • 3,179
  • 13
  • 53
  • 96
0
votes
1 answer

Floated div to fill remainder space

I have a CodePen for this set up here: http://codepen.io/anon/pen/Isqou div.linksBox { border:1px solid #a9a9a9; background:#fff; -moz-box-shadow:0 5px 12px rgba(0,0,0,0.3); -webkit-box-shadow:0 5px 12px rgba(0,0,0,0.3); box-shadow:0 5px 12px…
XyberICE
  • 525
  • 2
  • 7
  • 16
0
votes
2 answers

Make an input take up all the remaining space

My problem is similar to this question, but different. I have a table cell of an unknown width. This cell contains an input and a span. The span should be as wide as its contents needs and the input should take all the remaining space. I've created…
maaartinus
  • 44,714
  • 32
  • 161
  • 320