是否可以在android中创建一个具有两个可点击区域的按钮?如果是,怎么办?谢谢你的帮助。
您可以添加两个按钮,使用背景图像并将边距设置为0,这样它们实际上看起来就像一个按钮。
没有,但您可以创建两个看起来像一个按钮的按钮。将两个按钮紧挨着放置。创建一个覆盖两个按钮的位图图像。把图像切成两半。将按钮的背景图像设置为两个位图。
第一个答案为否。但你可以把两个标签组合在一起有相同的按钮类型视图。将两个标签(或任何其他视图)放在同一布局中。为该布局设置侦听器。
您可以将图像与地图部分一起使用,每个部分都将执行不同的javascript。该图像将充当一个按钮,具有不同的目标操作。
例如,看看这里的代码
<img src ="planets.gif" width ="145" height ="126" alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape ="rect" coords ="0,0,82,126"
onmouseover="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')"
href ="sun.htm" target ="_blank" alt="Sun" />
<area shape ="circle" coords ="90,58,3"
onmouseover="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="124,58,8"
onmouseover="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map>