Reputation: 3652
The Android Developer guidance on Creating a Custom Dialog specifies a layout that starts:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
If I use this code I get a dialog that sits in the centre of the screen with about 40 pixels of the underlying view visible on each side.
What exactly does "fill_parent" mean (for the width and height)?
Upvotes: 3
Views: 7477
Reputation: 3652
In answer to Octavian Damiean, I have written an app following the code set out in Creating A Custom Dialog. I have put the specified java code in the blank application's onCreate method (after super.onCreate(...) and setContentView(...). In order to make it run I have changed the Java code where it says "Context mContext = getApplicationContext();" to "Context mContext = this;" and at the end I have added the line "dialog.show();" to display the dialog.
The resulting screen looks like this:
Although both height and width are set to fill_parent the width is a bit smaller than the screen width and the height is very much smaller than the screen height.
I don't think padding works the way you suggest. Changing it from 10dip to 0dip makes no discernible difference (there is still a gap between the edge of the screen and the edge of the dialog.) Changing it to 100 dip results in this:
I think that padding affects the spacing of objects within the View rather than the spacing of the View within its parent.
Upvotes: 1
Reputation: 39605
It actually means what it says. It fills the entire space of its parent container. In this case minus 10dip
on each side (i.e. left, top, right, bottom) due to the padding attribute. If it would be set to wrap_content
instead it would take up only as much space as it needs to display its content.
Here is more information about fill_parent and here about the ViewGroup.LayoutParams.
Upvotes: 0