5
望着Drawable文档,我们有一个新的方法setHotspot (float x, float y)
用的描述:Android 5.0(API 21)上可绘制setHotspot的用途是什么?
指定绘制中的热点位置。
在该页面上没有其他解释,我不知道目的是什么。
望着Drawable文档,我们有一个新的方法setHotspot (float x, float y)
用的描述:Android 5.0(API 21)上可绘制setHotspot的用途是什么?
指定绘制中的热点位置。
在该页面上没有其他解释,我不知道目的是什么。
热点用于将触摸事件传递到RippleDrawable,但也可以由自定义可绘制使用。如果您正在实现一个自定义视图来管理自己的可绘制对象,则需要从drawableHotspotChanged()方法调用setHotspot()方法,以使触摸居中的涟漪能够正常工作。
从View.java:
@Override
public boolean onTouchEvent(MotionEvent event) {
...
case MotionEvent.ACTION_MOVE:
drawableHotspotChanged(x, y);
...
}
/**
* This function is called whenever the view hotspot changes and needs to
* be propagated to drawables managed by the view.
* <p>
* Be sure to call through to the superclass when overriding this function.
*
* @param x hotspot x coordinate
* @param y hotspot y coordinate
*/
public void drawableHotspotChanged(float x, float y) {
if (mBackground != null) {
mBackground.setHotspot(x, y);
}
}
从FrameLayout.java,它管理自己的mForeground绘制:
@Override
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (mForeground != null) {
mForeground.setHotspot(x, y);
}
}
我发现这篇文章(但它是旧):HTTP:// blahti .wordpress.com/2012/06/26/images-with-clickable-areas /也许这个热点有相同的感觉... – krossovochkin 2014-10-20 08:58:33
通过鼻子,这是设置为触摸感的点的坐标? – 2014-10-20 09:04:47