0

我一直在寻找答案,但提供的解决方案并没有解决我的问题。

我有一个显示一些视图(几个按钮和一个背景)的布局。为此,我添加了一个自定义控件,我已经扩展了线性布局。这个控件很好地显示在布局上方。我想要做的是添加一个额外的 ImageView,它比这个控件大,但它会在它的前面。

编辑:对不起,我希望这能解决问题。

我的活动有一个大布局(相对),我想在这个布局上堆叠两个额外的视图\布局,所以最终版本将是所附图片:

在此处输入图像描述

这是我的布局 - 它将图像视图堆叠在菜单栏上,而不是其他的。试图将 FrameLayout 放在其他地方仍然没有给我想要的结果。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background">
    <RelativeLayout android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="450dip">
        <com.myproject.controls.SearchControl
            android:id="@+id/scSearch" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
        />
        <ExpandableListView android:id="@+id/lstItems"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/scSearch"
            android:layout_marginLeft="26dip"
        />
    </RelativeLayout>
    <FrameLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <com.myproject.controls.MenubarMain
        android:id="@+id/mbMenuBarMain"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
    />
    <ImageView android:src="@drawable/myicon"
                android:layout_width="200dip"
                android:layout_height="200dip"
                />
    </FrameLayout>
</LinearLayout>
4

1 回答 1

0

不确定这是否可行,因为我正在工作中输入此内容。但是这里的故事的寓意是习惯使用RelativeLayout。您可以更好地控制布局。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background">
    <com.myproject.controls.MenubarMain
        android:id="@+id/mbMenuBarMain"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
    </com.myproject.controls.MenubarMain>
    <com.myproject.controls.SearchControl
        android:id="@+id/scSearch" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">
    </com.myproject.controls.SearchControl>
    <ExpandableListView android:id="@+id/lstItems"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/scSearch"
        android:layout_above="@id/mbMenuBarMain"
        android:layout_paddingLeft="26dp"/>
    <ImageView android:src="@drawable/myicon"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_alignBottom="@id/mbMenuBarMain"
            android:layout_alignRight="@id/mbMenuBarMain"/>
</RelativeLayout>
于 2011-08-24T17:04:44.620 回答