【发布时间】:2014-08-02 18:43:15
【问题描述】:
我想让位图的一部分可点击,我的布局如下所示:
________________________________
| ##### |
| ##### |
| ___________________ |
| | | |
| | | |
| | image | |
| | | |
| | | |
| ___________________ |
________________________________
我认为最简单的方法是在具有相对布局的图像上放置一个按钮:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ImageView>
<Button
android:id="@+id/Button"
android:layout_width="200dip"
android:layout_height="150dip"/>
</RelativeLayout>
但我还没有想出如何让按钮与图像的左上角对齐(而不是像现在那样与相对布局的左上角对齐)。这可能与相对布局吗?
也欢迎提出其他方法的建议,我考虑过: http://blahti.wordpress.com/2012/06/26/images-with-clickable-areas/ 但对于我的简单矩形区域来说,这似乎有点矫枉过正。
【问题讨论】:
标签: android android-layout android-relativelayout