本文整理汇总了Java中com.nineoldandroids.view.ViewHelper类的典型用法代码示例。如果您正苦于以下问题:Java ViewHelper类的具体用法?Java ViewHelper怎么用?Java ViewHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewHelper类属于com.nineoldandroids.view包,在下文中一共展示了ViewHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeScroll
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
@Override
public void computeScroll() {
if (mScroller.computeScrollOffset()) {
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
scrollX=mScroller.getCurrX();
// 这里是判断打开菜单时即向右滑动菜单向右滑动 实现视觉差滑动效果,scrollX就是监听startScroll开始滚动程X的值,因为getScrollX()只是监听手在屏幕上滑动的过程,手离开后就要在这里监听,0.7是可以根据需求改动
if(scrollX<oldX){
// Log.d("gaolei", "scrollX2--------------------------------|"+scrollX);
ViewHelper.setTranslationX(getChildAt(0), (menuWidth+scrollX)* 0.7f);
}
// 这里是判断点击菜单按钮关闭时,对菜单做处理,已达到视觉差效果,不然的话没有
if(clickMenuToClose){
ViewHelper.setTranslationX(getChildAt(0), (menuWidth+scrollX)* 0.7f);
}
oldX=scrollX;
postInvalidate();
}
}
示例2: slidingToY
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
public void slidingToY(View view ,float y){
if(view == null){
return;
}
view.clearAnimation();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
view.setY(y);
}else{
ViewHelper.setY(view, y);
}
}
示例3: transformPage
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
@Override
public void transformPage(View page, float position) {
if (position < -1) {
ViewHelper.setRotation(page, 0);
} else if (position <= 1) {
if (position < 0) {
mRot = (ROT_MAX * position);
ViewHelper.setPivotX(page, page.getMeasuredWidth() * 0.5f);
ViewHelper.setPivotY(page, page.getMeasuredHeight());
ViewHelper.setRotation(page, mRot);
} else {
mRot = (ROT_MAX * position);
ViewHelper.setPivotX(page, page.getMeasuredWidth() * 0.5f);
ViewHelper.setPivotY(page, page.getMeasuredHeight());
ViewHelper.setRotation(page, mRot);
}
} else {
ViewHelper.setRotation(page, 0);
}
}
示例4: onScrollChanged
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
float scale = l * 1.0f / mMenuWidth;
float leftScale = 1 - 0.3f * scale;
float rightScale = 0.8f + scale * 0.2f;
// ViewHelper.setScaleX(mMenu, leftScale);
// ViewHelper.setScaleY(mMenu, leftScale);
// ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale));
// Log.d("gaolei","mMenuWidth----------------"+mMenuWidth);
// Log.d("gaolei","l---------------"+l);
// Log.d("gaolei","scale----------------"+l * 1.0f / mMenuWidth);
// Log.d("gaolei"," mMenuWidth * scale * 0.7f----------------"+ mMenuWidth * scale * 0.7f);
ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.7f);
// ViewHelper.setPivotX(mContent, 0);
// ViewHelper.setPivotY(mContent, mContent.getHeight() / 2);
// ViewHelper.setScaleX(mContent, rightScale);
// ViewHelper.setScaleY(mContent, rightScale);
}
示例5: animateRotate
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
private void animateRotate(View left, View right, float positionOffset, boolean up) {
if (mState != State.IDLE) {
if (left != null) {
manageLayer(left, true);
mRot = (up ? 1 : -1) * (ROT_MAX * positionOffset);
mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
ViewHelper.setPivotY(left, up ? 0 : left.getMeasuredHeight());
ViewHelper.setTranslationY(left, mTrans);
ViewHelper.setRotation(left, mRot);
}
if (right != null) {
manageLayer(right, true);
mRot = (up ? 1 : -1) * (-ROT_MAX + ROT_MAX*positionOffset);
mTrans = (up ? -1 : 1) * (float) (getMeasuredHeight() - getMeasuredHeight()*Math.cos(mRot*Math.PI/180.0f));
ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
ViewHelper.setPivotY(right, up ? 0 : right.getMeasuredHeight());
ViewHelper.setTranslationY(right, mTrans);
ViewHelper.setRotation(right, mRot);
}
}
}
示例6: 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();
}
}
示例7: onDraw
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!placedBall) {
placeBall();
}
Paint paint = new Paint();
paint.setColor(backgroundColorLine);
paint.setStrokeWidth(dpToPx(3, getResources()));
canvas.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint);
paint.setColor(backgroundColor);
float division = (ball.xFin - ball.xIni) / (max - min);
int value = this.value - min;
canvas.drawLine(getHeight() / 2, getHeight() / 2, value * division + getHeight() / 2, getHeight() / 2, paint);
if (press) {
paint.setColor(backgroundColor);
paint.setAntiAlias(true);
canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 4, paint);
}
invalidate();
}
示例8: animateTablet
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
protected void animateTablet(View left, View right, float positionOffset) {
if (mState != State.IDLE) {
if (left != null) {
manageLayer(left, true);
mRot = 30.0f * positionOffset;
mTrans = getOffsetXForRotation(mRot, left.getMeasuredWidth(),
left.getMeasuredHeight());
ViewHelper.setPivotX(left, left.getMeasuredWidth()/2);
ViewHelper.setPivotY(left, left.getMeasuredHeight()/2);
ViewHelper.setTranslationX(left, mTrans);
ViewHelper.setRotationY(left, mRot);
logState(left, "Left");
}
if (right != null) {
manageLayer(right, true);
mRot = -30.0f * (1-positionOffset);
mTrans = getOffsetXForRotation(mRot, right.getMeasuredWidth(),
right.getMeasuredHeight());
ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
ViewHelper.setTranslationX(right, mTrans);
ViewHelper.setRotationY(right, mRot);
logState(right, "Right");
}
}
}
示例9: animateCube
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
private void animateCube(View left, View right, float positionOffset, boolean in) {
if (mState != State.IDLE) {
if (left != null) {
manageLayer(left, true);
mRot = (in ? 90.0f : -90.0f) * positionOffset;
ViewHelper.setPivotX(left, left.getMeasuredWidth());
ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
ViewHelper.setRotationY(left, mRot);
}
if (right != null) {
manageLayer(right, true);
mRot = -(in ? 90.0f : -90.0f) * (1-positionOffset);
ViewHelper.setPivotX(right, 0);
ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
ViewHelper.setRotationY(right, mRot);
}
}
}
示例10: animateAccordion
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
private void animateAccordion(View left, View right, float positionOffset) {
if (mState != State.IDLE) {
if (left != null) {
manageLayer(left, true);
ViewHelper.setPivotX(left, left.getMeasuredWidth());
ViewHelper.setPivotY(left, 0);
ViewHelper.setScaleX(left, 1-positionOffset);
}
if (right != null) {
manageLayer(right, true);
ViewHelper.setPivotX(right, 0);
ViewHelper.setPivotY(right, 0);
ViewHelper.setScaleX(right, positionOffset);
}
}
}
示例11: animateZoom
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
private void animateZoom(View left, View right, float positionOffset, boolean in) {
if (mState != State.IDLE) {
if (left != null) {
manageLayer(left, true);
mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*(1-positionOffset) :
1+ZOOM_MAX - ZOOM_MAX*(1-positionOffset);
ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
ViewHelper.setScaleX(left, mScale);
ViewHelper.setScaleY(left, mScale);
}
if (right != null) {
manageLayer(right, true);
mScale = in ? ZOOM_MAX + (1-ZOOM_MAX)*positionOffset :
1+ZOOM_MAX - ZOOM_MAX*positionOffset;
ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
ViewHelper.setScaleX(right, mScale);
ViewHelper.setScaleY(right, mScale);
}
}
}
示例12: animateStack
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
protected void animateStack(View left, View right, float positionOffset, int positionOffsetPixels) {
if (mState != State.IDLE) {
if (right != null) {
manageLayer(right, true);
mScale = (1-SCALE_MAX) * positionOffset + SCALE_MAX;
mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
ViewHelper.setScaleX(right, mScale);
ViewHelper.setScaleY(right, mScale);
ViewHelper.setTranslationX(right, mTrans);
}
if (left != null) {
left.bringToFront();
}
}
}
示例13: liftingFromBottom
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
/**
* Lifting view
*
* @param view The animation target
* @param baseRotation initial Rotation X in 3D space
* @param fromY initial Y position of view
* @param duration aniamtion duration
* @param startDelay start delay before animation begin
*/
@Deprecated
public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay) {
ViewHelper.setRotationX(view, baseRotation);
ViewHelper.setTranslationY(view, fromY);
ViewPropertyAnimator
.animate(view)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setDuration(duration)
.setStartDelay(startDelay)
.rotationX(0)
.translationY(0)
.start();
}
示例14: onTransform
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
@Override
protected void onTransform(View view, float position) {
// Page is not an immediate sibling, just make transparent
if(position < -1 || position > 1) {
ViewHelper.setAlpha(view,0.6f);
}
// Page is sibling to left or right
else if (position <= 0 || position <= 1) {
// Calculate alpha. Position is decimal in [-1,0] or [0,1]
float alpha = (position <= 0) ? position + 1 : 1 - position;
ViewHelper.setAlpha(view,alpha);
}
// Page is active, make fully visible
else if (position == 0) {
ViewHelper.setAlpha(view,1);
}
}
示例15: animateView
import com.nineoldandroids.view.ViewHelper; //导入依赖的package包/类
private void animateView(float percent) {
float f1 = 1 - percent * 0.3f;
ViewHelper.setScaleX(vg_main, f1); //主布局逐渐变大
ViewHelper.setScaleY(vg_main, f1);
ViewHelper.setTranslationX(vg_left, -vg_left.getWidth() / 2.3f
+ vg_left.getWidth() / 2.3f * percent);
ViewHelper.setScaleX(vg_left, 0.5f + 0.5f * percent);//左边的布局逐渐变小
ViewHelper.setScaleY(vg_left, 0.5f + 0.5f * percent);
ViewHelper.setAlpha(vg_left, percent);
if (isShowShadow) {
ViewHelper.setScaleX(iv_shadow, f1 * 1.4f * (1 - percent * 0.12f));
ViewHelper.setScaleY(iv_shadow, f1 * 1.85f * (1 - percent * 0.12f));
}
getBackground().setColorFilter(
evaluate(percent, Color.BLACK, Color.TRANSPARENT),
Mode.SRC_OVER);
}