假设我想在另一个具有不同背景颜色的布局中进行布局,但是一旦我向内部布局(在这种情况下为frameLayout6)添加了背景颜色,外部布局的背景就会变得透明...



任何想法可能有什么问题吗?

谢谢!

                <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>

最佳答案

内部布局(frameLayout6)在framelayout5上方,因此,如果在内部布局中设置背景,则看不到framelayout5。

编辑:

我不知道为什么会这样,但是你可以做到

<?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>

10-07 19:28
查看更多