mario595
mario595

Reputation: 3761

Android: LinearLayout with match_parent doesn't Match Parent

I have the following xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/filters_view_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#ededed"
  android:orientation="vertical"
  android:paddingLeft="20dp"
  android:paddingRight="20dp" >

   <ExpandableListView
       android:id="@+id/filters_List"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:divider="#00000000">
   </ExpandableListView>

</LinearLayout>

The LinearLayout has a gray background. I want this background to fill the whole screen (the space between the blue bar and the black bar), so I set the height of the LinearLayout to match_parent, but it keeps wrapping the list that contents, so I get a white gap. Here is how it looks like:

enter image description here

Anybody could give me a hint about how to make this?

Thanks!

EDIT: petrumo and Tanis.7x were almost right. Some parent views wasn't taking all the available space. I fixed it, and now all the parent views are taking all the space. The first view that isn't filling the space is the LinearLayout I posted (with ID filters_view_container). It has android:layout_height="match_parent" so I don't understand why is not taking all the space.

I am adding a snapshot of the hierarchy viewer with this LinearLayout selected.

enter image description here

Upvotes: 4

Views: 9977

Answers (2)

user3148156
user3148156

Reputation: 178

you didnt post your edit text xml; anyways the listview IS filling/matching the parent, but your root view specified left and right padding of 20dp. So it filled the root layout where the root layout has left 20dp and right 20dp

Upvotes: 0

petrumo
petrumo

Reputation: 1116

Probably the problem is one level higher, the previous View is not taking the entire space. If you post more layout code I can give more hints.

Upvotes: 3

Related Questions