2

FrameLayout's layout_weight is 0.13 but it looks like much bigger than it. Why? A lot of reccomendations are android:layout_height="0dp", but it doesn't help.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent" android:background="@drawable/background" android:weightSum="1">

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp" android:background="@drawable/bar_background" android:layout_weight="0.13">
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/header"
                android:id="@+id/textView" android:layout_gravity="center" android:textSize="@dimen/header_size"
                android:textColor="#ffffff" android:layout_marginTop="@dimen/header_margin_top" />
    </FrameLayout>
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <EditText
                android:inputType="text"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:id="@+id/textEdit"/>
        <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/imageView" android:layout_gravity="center" android:src="@drawable/separator"
                android:scaleType="fitXY"/>
        <ListView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/listView" android:layout_gravity="center" android:choiceMode="singleChoice"
                android:scrollingCache="false" android:cacheColorHint="#00000000"/>
    </LinearLayout>
</LinearLayout>

4 Answers 4

2

I think it might be because none of the FrameLayout's siblings have a weight. Try adding a weight (probably .87) to your inner LinearLayout and see if that fixes the issue.

1
  • Did you also set the inner LinearLayout's height to 0dp when you did this?
    – berwyn
    Feb 15, 2013 at 22:01
1

Sorry, looks like it's IntelliJ IDEA's preview bug. All is good on the device. Thanks all.

0

I've tried your layout and after setting a weight of 0.87 and a layout_height of 0dp to the sibling LinearLayout it works fine to me. Maybe the dimensions you are setting to the inner TextView in the FrameLayout are too large?

0
0
android:textSize="@dimen/header_size"

I think because of this is too large so it force you FrameLayout to be larger than it should be

1
  • Unset margin and textSize - text became very small, but FrameLayout's height didn't change.
    – Vladiator
    Feb 16, 2013 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.