本文整理汇总了Java中com.nineoldandroids.view.ViewHelper.setX方法的典型用法代码示例。如果您正苦于以下问题:Java ViewHelper.setX方法的具体用法?Java ViewHelper.setX怎么用?Java ViewHelper.setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nineoldandroids.view.ViewHelper
的用法示例。
在下文中一共展示了ViewHelper.setX方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValue
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
public void setValue(final int value) {
if (placedBall == false)
post(new Runnable() {
@Override
public void run() {
setValue(value);
}
});
else {
this.value = value;
float division = (ball.xFin - ball.xIni) / max;
ViewHelper.setX(ball, value * division + getHeight() / 2 - ball.getWidth() / 2);
ball.changeBackground();
}
}
示例2: onTouchEvent
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isEnabled()) {
isLastTouch = true;
if (event.getAction() == MotionEvent.ACTION_DOWN) {
press = true;
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
requestDisallowInterceptTouchEvent(true);
float x = event.getX();
x = (x < ball.xIni) ? ball.xIni : x;
x = (x > ball.xFin) ? ball.xFin : x;
if (x > ball.xCen) {
iSchecked = true;
} else {
iSchecked = false;
}
ViewHelper.setX(ball, x);
ball.changeBackground();
if (event.getX() <= getWidth() && event.getX() >= 0) {
isLastTouch = false;
press = false;
}
} else if (event.getAction() == MotionEvent.ACTION_UP
|| event.getAction() == MotionEvent.ACTION_CANCEL) {
requestDisallowInterceptTouchEvent(false);
press = false;
isLastTouch = false;
if (eventCheck != iSchecked) {
eventCheck = iSchecked;
if (onCheckListener != null)
onCheckListener.onCheck(iSchecked);
}
if (event.getX() <= getWidth() && event.getX() >= 0) {
ball.animateCheck();
}
}
}
return true;
}
示例3: placeBall
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
private void placeBall() {
ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
ball.xIni = ViewHelper.getX(ball);
ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
placedBall = true;
ball.animateCheck();
}
示例4: placeBall
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
private void placeBall() {
ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
ball.xIni = ViewHelper.getX(ball);
ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
placedBall = true;
}
示例5: setValueInRunnable
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
private void setValueInRunnable(final int value,final boolean inRunnable) {
if(placedBall == false && inRunnable == true)
post(new Runnable() {
@Override
public void run() {
setValue(value,inRunnable);
}
});
else{
this.value = value;
float division = (ball.xFin - ball.xIni) / max;
ViewHelper.setX(ball,value*division + getHeight()/2 - ball.getWidth()/2);
ball.changeBackground();
}
}
示例6: onDraw
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (numberIndicatorResize == false) {
RelativeLayout.LayoutParams params = (LayoutParams) numberIndicator.
numberIndicator.getLayoutParams();
params.height = (int) finalSize * 2;
params.width = (int) finalSize * 2;
numberIndicator.numberIndicator.setLayoutParams(params);
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(backgroundColor);
if (animate) {
if (y == 0)
y = finalY + finalSize * 2;
y -= Utils.dpToPx(6, getResources());
size += Utils.dpToPx(2, getResources());
}
canvas.drawCircle(
ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent())
+ ball.getWidth() / 2, y, size, paint);
if (animate && size >= finalSize)
animate = false;
if (animate == false) {
ViewHelper.setX(numberIndicator.numberIndicator,
(ViewHelper.getX(ball) + Utils.getRelativeLeft((View) ball.getParent()) + ball.getWidth() / 2) - size);
ViewHelper.setY(numberIndicator.numberIndicator, y - size);
numberIndicator.numberIndicator.setText(value + "");
}
invalidate();
}
示例7: placeBall
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
private void placeBall() {
ViewHelper.setX(ball, getHeight() / 2 - ball.getWidth() / 2);
ball.xIni = ViewHelper.getX(ball);
ball.xFin = getWidth() - getHeight() / 2 - ball.getWidth() / 2;
ball.xCen = getWidth() / 2 - ball.getWidth() / 2;
placedBall = true;
}
示例8: onTouchEvent
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
isLastTouch = true;
if (isEnabled()) {
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
if (numberIndicator != null && numberIndicator.isShowing() == false)
numberIndicator.show();// 只要一按下就会冒出指示器
if ((event.getX() <= getWidth() && event.getX() >= 0)) {
press = true;
// calculate value
int newValue = 0;
float division = (ball.xFin - ball.xIni) / (max - min);
if (event.getX() > ball.xFin) {
newValue = max;
} else if (event.getX() < ball.xIni) {
newValue = min;
} else {
newValue = min + (int) ((event.getX() - ball.xIni) / division);
}
if (value != newValue) {
value = newValue;
if (onValueChangedListener != null)
onValueChangedListener.onValueChanged(newValue);
}
// move ball indicator
float x = event.getX();
x = (x < ball.xIni) ? ball.xIni : x;
x = (x > ball.xFin) ? ball.xFin : x;
ViewHelper.setX(ball, x);
ball.changeBackground();
// If slider has number indicator
if (numberIndicator != null) {
// move number indicator
numberIndicator.indicator.x = x;
// 指示器起始的y坐标是当前控件的顶部Y坐标-当前控件高度的一半,就等于从空间的垂直中心开始。
numberIndicator.indicator.finalY = Utils.getRelativeTop(this) - getHeight() ;
numberIndicator.indicator.finalSize = getHeight() / 2;
numberIndicator.numberIndicator.setText("");
}
} else {
press = false;
isLastTouch = false;
if (numberIndicator != null)
numberIndicator.dismiss();
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (numberIndicator != null)
numberIndicator.dismiss();
isLastTouch = false;
press = false;
if ((event.getX() <= getWidth() && event.getX() >= 0)) {
}
}
}
return true;
}
示例9: onTouchEvent
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
isLastTouch = true;
if (isEnabled()) {
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
if ((event.getX() <= getWidth() && event.getX() >= 0)) {
press = true;
// calculate value
int newValue = 0;
float division = (ball.xFin - ball.xIni) / (max - min);
if (event.getX() > ball.xFin) {
newValue = max;
} else if (event.getX() < ball.xIni) {
newValue = min;
} else {
newValue = min + (int) ((event.getX() - ball.xIni) / division);
}
if (value != newValue) {
value = newValue;
if (onValueChangedListener != null)
onValueChangedListener.onValueChanged(newValue);
}
// move ball indicator
float x = event.getX();
x = (x < ball.xIni) ? ball.xIni : x;
x = (x > ball.xFin) ? ball.xFin : x;
ViewHelper.setX(ball, x);
ball.changeBackground();
} else {
press = false;
isLastTouch = false;
}
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
press = false;
}
}
return true;
}