本文整理匯總了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);
}