Search code examples
androidandroid-linearlayoutandroid-framelayout

LinearLayout being pushed off the screen


So for my landscape layout of a page, I want to have a sort of horizontal layout. However, my FrameLayout including my ListView goes off the screen, even though it's set to android:layout_width="match_parent". Here's a screenshot of what I mean:

ss

The blue line is the outline of where the FrameLayout is going, when it is set to match parent.

Here's my XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/contactlist"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/brushed_metal_background_dark"
    android:orientation="vertical"
    tools:context=".ContactList" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/headerbackground"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_weight="1"
            android:scaleType="center"
            android:src="@drawable/homeheader7" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:paddingRight="3sp"
            android:text="@string/version"
            android:textColor="#FFFFFF"
            android:textStyle="italic" >
        </TextView>

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:onClick="setOptions"
            android:src="@drawable/menu" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical" >

            <ImageButton
                android:id="@+id/report"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@null"
                android:gravity="left"
                android:onClick="report"
                android:scaleType="center"
                android:src="@drawable/submit_report" />
        </LinearLayout>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:paddingLeft="3dp"
            android:paddingRight="3dp"
            android:scaleType="center"
            android:src="@drawable/divider_ver" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical" >

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:scaleType="center"
                android:src="@drawable/schoolfeed2" />

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="100"
                android:background="@drawable/background_overlay_dark"
                android:duplicateParentState="false"
                android:fadingEdge="horizontal"
                android:paddingBottom="9dp"
                android:paddingLeft="16dp"
                android:paddingRight="10dp"
                android:paddingTop="7dp" >

                <ListView
                    android:id="@+id/schoolFeed"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:dividerHeight="2dp"
                    android:footerDividersEnabled="false"
                    android:headerDividersEnabled="true"
                    android:scrollbarDefaultDelayBeforeFade="50000"
                    android:scrollbarStyle="outsideInset"
                    android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
                    android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track" >
                </ListView>
            </FrameLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

Any help is appreciated! Thanks,


Solution

  • I would recommend you that, instead of using match_parent, use wrap_content, becuase, actually, whats happening is that the framelayout has the same width of the screen, so, as it isn't at the left of the screen, it goes off.