1

Say I want to make one layout inside another one with different background colors, but once I add a background color to the inner layout ( frameLayout6 in this case ), the outer layout's background becomes transparent...

enter image description here

any ideas what might be wrong?

Thanks!

                <FrameLayout
                    android:id="@+id/frameLayout5"
                    android:layout_width="160px"
                    android:layout_height="160px" android:background="#FFFFFF" android:layout_marginLeft="20px">

                    <FrameLayout
                        android:id="@+id/frameLayout6"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" android:layout_margin="5px">
                    </FrameLayout>

                </FrameLayout>
kaiz.net
  • 1,984
  • 3
  • 23
  • 31
Roger Travis
  • 8,402
  • 18
  • 67
  • 94

1 Answers1

1

The inner layout (frameLayout6) is over framelayout5 so if you set a background in the inner layout, you can't see the framelayout5.

Edit:

I don't know why this behavior happen but you can do that

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout android:id="@+id/frameLayout5"
         android:layout_height="160dp"
        android:layout_marginLeft="20dp" android:layout_width="160dp">

        <View android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ff00ff"/>

        <RelativeLayout android:layout_width="fill_parent"
            android:background="#ff0000" android:layout_height="fill_parent"
            android:layout_margin="50dp" android:drawingCacheQuality="auto">
        </RelativeLayout>

    </RelativeLayout>
</LinearLayout>
FUBUs
  • 617
  • 5
  • 9
  • But it has margin and even if I add padding, it still is not viable. – Roger Travis Apr 18 '12 at 20:09
  • For the case of margin, you must see the background of framelayout5. In the case of padding, you must see just the background of framelayout6 http://stackoverflow.com/questions/4619899/difference-between-a-views-padding-and-margin – FUBUs Apr 18 '12 at 20:10
  • it's weird, have you try to change the kind of layout, for exemple LinearLayout instead of FrameLayout – FUBUs Apr 18 '12 at 20:14