问题描述
在我的Android应用程序,我有整个全球3不规则形状如下:
In my Android Application, I have three irregular shape across globe as below :
所以我在布局放在这个整体的形象。地球只是一个形象。有全球任何作用在这里。
现在我想放在了最上面的一个按钮,每个不规则形状的图像这是在全球范围内。
So I placed this whole image in layout.Globe is just an image .There is no role of globe here.
Now I want to place one buttons on top of the each irregular shaped images which are across the globe.
按钮始终是矩形,但我想触摸事件的不规则形状,不为矩形区域。
所以,我怎么可以把三个按钮,这三个不规则形状或有什么解决办法?所以不同的事件,每一个按钮就可以在活动如何处理?
Button is always rectangular but I want to get touch event for irregular shape,not for rectangular area.
So How can I put three buttons on these three irregular shape or is there any solution? so that different event for each button can be handled in activity?
我没有想法就如何实现这一任务。请指导我在此。
I don't have idea on how to achieve this task. Please guide me on this.
任何意见或建议?
任何帮助将AP preciated。
Any help will be appreciated.
推荐答案
从上面的回答,我得到了暗示,最后我得到了如下解决方案:
From above answers,I got hint and finally I got Solution as below:
我所做的是:
在XML文件中使用RelativeLayout的
Used RelativeLayout in xml file
用于ImageView的,如下:
Used ImageView, as below :
<ImageView
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/glob2"
android:layout_marginBottom="24dp"
android:layout_marginLeft="80.5dp"
android:contentDescription="@string/profile_picture_description"
android:src="@drawable/pick_matches_background" />
在这里我设置相应的保证金(左/右/底/顶)。
Here I set the margin accordingly(left/right/bottom/top).
在活动中,
声明
Bitmap btmp; and
ImageView img;
在onCreate方法,
In onCreate Method,
// initialized image view
img = (ImageView) findViewById(R.id.btn1);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// call your method here
}
});
StateListDrawable sdCreateTrip = (StateListDrawable) img
.getDrawable();
btmp = ((BitmapDrawable) sdCreateTrip.getCurrent())
.getBitmap();
您已经准备好走了。
这篇关于用于放置按钮(Android的布局)解决方案上的不规则形状的图像的图像的特定区域的顶部或获得触摸检测(可触摸区域)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!