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
2
votes
7 answers

fill parent on a textview doesn't apply

I know this question has been asked multiple times, but I have looked on all the solution I could see and none of them worked. I have a textview inside a relative-layout. the textview has a height : fill_parent atribute that does not work. the pun…
wazaminator
  • 245
  • 3
  • 15
1
vote
1 answer

Android custom layout manager - layout in children

I have created a custom layout manager derived from LinearLayout. (I do not really use much of LinearLayout functionality but I do not want to care about all of many ViewGroup abstract methods.) I have overwritten only protected void…
1
vote
2 answers

Webview doesn't fit fullscreen with action bar on

I want to have webview displayed fullscreen with action bar on top of it and standard menu bar on bottom. It's displayed correctly without action bar. When I am turning it on, bottom part of webview is displayed under bottom menu bar and I want to…
Piotr
  • 1,743
  • 1
  • 26
  • 40
1
vote
2 answers

Question about DP in Android

Let's say I prefer using "dp" rather than "fill_parent" or "wrap_content", what would be the appropriate number to use in order to fill the screen with a picture?
user858975
  • 233
  • 1
  • 7
  • 17
1
vote
1 answer

Android: height of LinearLayout didn't fill parent of ListView item

I have a ListView, the item is a RelativeLayout, at left is text, and the right side is ImageView in a LinearLayout. I expect the height of the LinearLayout**(white background)** to be fillParent but it didn't. The effect is : Anyone can help on…
Lune
  • 241
  • 1
  • 3
  • 13
1
vote
2 answers

Android: layout with match_parent shall take the space left or share

I have a horizontal Linear Layout, containing two Layouts. I want the right layout to be as wide as the content (wrap_content). The left layout shall fill remaining space. I tried with "match_parent" on the left layout(Relative Layout) and…
Mehmet Ates
  • 135
  • 1
  • 2
  • 11
1
vote
0 answers

Layout doesn't fill frame layout in android 2.3

I have a FrameLayout with two LinearLayouts inside. For Android version 4.x it works fine but for version 2.3 second LinearLayout doesn't fill FrameLayout vertically. Can anyone tell me why? Btw I know I set second LinearLayout as invisible but I…
dammarpol
  • 77
  • 1
  • 13
1
vote
1 answer

don't fill parent custom layout for action bar

I have three layouts: 1. calculate_actionbar_layout.xml 2. purchasingmanager_actionbar_layout.xml 3. usermanagement_layout.xml When I select a tab from action bar the relate layout for this tab with item show in action bar.but not fill custom layout…
Fouad
  • 131
  • 1
  • 11
1
vote
1 answer

Vertical LinearLayout with WrapContent width - make children fill it up to widest child

I want to create vertical LinearLayout with couple of Button children, where each child has width of widest of them. However depending on using MATCH_PARENT or WRAP_CONTENT for children width, I get either LinearLayout taking whole screen's width,…
Koger
  • 1,783
  • 2
  • 23
  • 34
1
vote
3 answers

Android - how to make TextView fill_parent in code

I'm trying to make my TextView layout_width to be fill parent throw code. this is my code: TextView WatchMovieTitle; private void PrintTheMovieAndYear() { if (CountWords() > 23) { // this is what im doing wrong // …
digitalmidges
  • 826
  • 3
  • 13
  • 24
0
votes
1 answer

Titanium mobile relative layout

I'm creating android app using Titanium mobile. How do I create this interface using vertical layout? ---------------- Header View } height = 40dp ----------------- Content View } height = fill_parent ---------------- In the…
Bananakilo
  • 1,323
  • 3
  • 14
  • 20
0
votes
1 answer

Table layout with rows filling parent but having same height

Does anyone know of a way to have a table layout with a number of rows having the same height but filling the parent? In the following layout all the rows will have the same height but if I add, say an image view to the first row, this row will…
simonbs
  • 7,932
  • 13
  • 69
  • 115
0
votes
3 answers

Stretching two layouts in parent layout

I am trying to achieve that the two nesting relative layouts take up an equal amount of space AND for the to fill out the whole width of the screen. All parent layouts have fillparent set on width. The graphical view in Eclipse looks fine, but my…
Ana
  • 23
  • 2
0
votes
1 answer

TabHost do not match is parent width in HoneyComb Android 3.0

I'm trying to make a TabHost on HoneyComb as if I was on 1.6+ but the fact is when I copy the code (which is the same for both HoneyComb and previous version), the TabHost do not match the screen width. I don't get it? Using Halo theme on API 3.0…
Leiko
  • 954
  • 8
  • 10
0
votes
2 answers

Android Listview width prob

Here is the main layout for a screen:
dev_android
  • 8,698
  • 22
  • 91
  • 148