本文整理汇总了Java中android.view.View.drawableHotspotChanged方法的典型用法代码示例。如果您正苦于以下问题:Java View.drawableHotspotChanged方法的具体用法?Java View.drawableHotspotChanged怎么用?Java View.drawableHotspotChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.drawableHotspotChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPressedItem
import android.view.View; //导入方法依赖的package包/类
private void setPressedItem(View child, int position, float x, float y) {
this.mDrawsInPressedState = true;
if (VERSION.SDK_INT >= 21) {
drawableHotspotChanged(x, y);
}
if (!isPressed()) {
setPressed(true);
}
layoutChildren();
if (this.mMotionPosition != -1) {
View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
if (!(motionView == null || motionView == child || !motionView.isPressed())) {
motionView.setPressed(false);
}
}
this.mMotionPosition = position;
float childX = x - ((float) child.getLeft());
float childY = y - ((float) child.getTop());
if (VERSION.SDK_INT >= 21) {
child.drawableHotspotChanged(childX, childY);
}
if (!child.isPressed()) {
child.setPressed(true);
}
positionSelectorLikeTouchCompat(position, child, x, y);
setSelectorEnabled(false);
refreshDrawableState();
}
示例2: onTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
showMenuRunnable = new Runnable() {
@Override
public void run() {
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
toggleSubMenu();
}
};
AndroidUtilities.runOnUIThread(showMenuRunnable, 200);
}
} else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
if (event.getY() > getHeight()) {
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
toggleSubMenu();
return true;
}
} else if (popupWindow != null && popupWindow.isShowing()) {
getLocationOnScreen(location);
float x = event.getX() + location[0];
float y = event.getY() + location[1];
popupLayout.getLocationOnScreen(location);
x -= location[0];
y -= location[1];
selectedMenuView = null;
for (int a = 0; a < popupLayout.getItemsCount(); a++) {
View child = popupLayout.getItemAt(a);
child.getHitRect(rect);
if ((Integer) child.getTag() < 100) {
if (!rect.contains((int) x, (int) y)) {
child.setPressed(false);
child.setSelected(false);
if (Build.VERSION.SDK_INT == 21) {
child.getBackground().setVisible(false, false);
}
} else {
child.setPressed(true);
child.setSelected(true);
if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT == 21) {
child.getBackground().setVisible(true, false);
}
child.drawableHotspotChanged(x, y - child.getTop());
}
selectedMenuView = child;
}
}
}
}
} else if (popupWindow != null && popupWindow.isShowing() && event.getActionMasked() == MotionEvent.ACTION_UP) {
if (selectedMenuView != null) {
selectedMenuView.setSelected(false);
if (parentMenu != null) {
parentMenu.onItemClick((Integer) selectedMenuView.getTag());
} else if (delegate != null) {
delegate.onItemClick((Integer) selectedMenuView.getTag());
}
popupWindow.dismiss(allowCloseAnimation);
} else {
popupWindow.dismiss();
}
} else {
if (selectedMenuView != null) {
selectedMenuView.setSelected(false);
selectedMenuView = null;
}
}
return super.onTouchEvent(event);
}