Android 将按钮放置在绝对位置的imageView上
我无法在图像视图上定位按钮 我想在图像视图的顶部放置一个按钮,以便按钮位于图像上 到目前为止,我已经在某种程度上做到了,比如Android 将按钮放置在绝对位置的imageView上,android,button,layout,imageview,Android,Button,Layout,Imageview,我无法在图像视图上定位按钮 我想在图像视图的顶部放置一个按钮,以便按钮位于图像上 到目前为止,我已经在某种程度上做到了,比如 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_widt
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
该按钮是在应用程序启动时通过编程方式添加的,因此该按钮显示在图像的顶部
它工作正常,但问题是当我缩放/拖动图像时
我希望按钮可以随图像移动/缩放,但根据上面的内容,按钮会停留在屏幕上的固定位置,只有图像被缩放/拖动
我有办法做到这一点吗
提前感谢。这将取决于按钮所对应的元素。请发布完整的xml代码,了解每个视图的属性可能有助于找到解决方案。@seise我用完整的xml编辑了内容。我设置了图像源,并从代码中将按钮创建并添加到relativeLayout中。您在哪里添加按钮,缩放/拖动代码修改了什么?在不查看更多代码的情况下,我猜当您缩放/拖动图像时,您只是更改ImageView的大小/位置,而不会影响按钮。如果是这种情况,请尝试在另一个布局中同时包装图像和按钮,并使缩放/拖动代码影响该布局,而不仅仅是图像。