Android 在Gallery视图中覆盖图像?
我想在叠加类型功能中将ImageButton添加到Gallery项目中。具体地说,我想有4个按钮被放置在画廊中的每个图像的顶部,当它们被按下时触发动作 非常感谢你在这件事上的任何帮助或暗示。下面是我的XML文件Android 在Gallery视图中覆盖图像?,android,android-layout,android-gallery,Android,Android Layout,Android Gallery,我想在叠加类型功能中将ImageButton添加到Gallery项目中。具体地说,我想有4个按钮被放置在画廊中的每个图像的顶部,当它们被按下时触发动作 非常感谢你在这件事上的任何帮助或暗示。下面是我的XML文件 这是我的TOPBUTTONS XML 您需要使用RelativeLayout,这是行上的东西 <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_p
这是我的TOPBUTTONS XML
您需要使用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>
我尝试了你的建议,但按钮无法应用于每个图像。只创建一组按钮。假设我的图库中有12个图像,我希望每个图像都有自己的按钮集。也许我需要操纵图像本身并覆盖图像?我不确定正确的方法是什么。好吧,我想你每个屏幕都有一张图片。如果您还没有找到解决方案,请尝试创建一个新的适配器,就像您为ListView所做的那样,并为您的多媒体资料设置它。
<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"/>
<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>