在Gallery View中叠加图像?

时间:2011-06-19 15:56:33

标签: android android-layout android-gallery

我想在叠加类型功能中将ImageButton添加到图库项目。具体来说,我希望在图库中的每个图像的顶部放置4个按钮,并在按下时触发操作。

非常感谢您对此事的任何帮助或暗示。下面是我的XML文件。

    <include layout="@layout/topnav_bar"/>

            <!-- These are my buttons -->
    <include layout="@layout/topbuttons"/>


    <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/runway"
        android:gravity="top"
        android:spacing="5dp"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

    <include layout="@layout/bottomnav_bar"/>

这是我的TOPBUTTONS XML     

    <ImageButton
    android:id="@+id/ibuy" 
    android:src="@drawable/ishop"
    android:onClick="@string/ibuy"
    android:scaleType="centerInside"
    android:layout_height="50dp" 
    android:layout_width="20dp" 
    android:layout_weight="1"/>
    <ImageButton 
    android:src="@drawable/izoom"
    android:scaleType="centerInside"
    android:layout_height="50dp" 
    android:layout_width="20dp" 
    android:layout_weight="1"/>
    <ImageButton 
    android:id="@+id/fblike"
    android:src="@drawable/ishare"
    android:onClick="@string/postToFaceBook"
    android:scaleType="centerInside"
    android:layout_height="50dp" 
    android:layout_width="20dp" 
    android:layout_weight="1"/>
    <ImageButton 
    android:id="@+id/ilove"
    android:src="@drawable/ilove"
    android:onClick="@string/rateIt"
    android:scaleType="centerInside"
    android:layout_height="50dp" 
    android:layout_width="20dp" 
    android:layout_weight="1"/>

1 个答案:

答案 0 :(得分:0)

你需要使用RelativeLayout,行

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation= "vertical"
    >
    <include layout="@layout/topnav_bar"/>
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <!-- These are my buttons -->
        <include 
            layout="@layout/topbuttons"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            />
        <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/runway"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            />
    </RelativeLayout>        
    <include layout="@layout/bottomnav_bar"/>
</LinearLayout>
相关问题