本文整理汇总了Java中android.view.View.setRotationX方法的典型用法代码示例。如果您正苦于以下问题:Java View.setRotationX方法的具体用法?Java View.setRotationX怎么用?Java View.setRotationX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setRotationX方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreTransform
import android.view.View; //导入方法依赖的package包/类
protected void onPreTransform(View page, float position) {
float f = 0.0f;
float width = (float) page.getWidth();
page.setRotationX(0.0f);
page.setRotationY(0.0f);
page.setRotation(0.0f);
page.setScaleX(1.0f);
page.setScaleY(1.0f);
page.setPivotX(0.0f);
page.setPivotY(0.0f);
page.setTranslationY(0.0f);
page.setTranslationX(isPagingEnabled() ? 0.0f : (-width) * position);
if (hideOffscreenPages()) {
if (position > -1.0f && position < 1.0f) {
f = 1.0f;
}
page.setAlpha(f);
return;
}
page.setAlpha(1.0f);
}
示例2: onPreTransform
import android.view.View; //导入方法依赖的package包/类
/**
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
page.setEnabled(false);
} else {
page.setEnabled(true);
page.setAlpha(1f);
}
}
示例3: onPreTransform
import android.view.View; //导入方法依赖的package包/类
/**
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
// page.setEnabled(false);
} else {
// page.setEnabled(true);
page.setAlpha(1f);
}
}
示例4: onPreTransform
import android.view.View; //导入方法依赖的package包/类
/**
* Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
} else {
page.setAlpha(1f);
}
}
示例5: onAnimationEnd
import android.view.View; //导入方法依赖的package包/类
@Override
public void onAnimationEnd(Animator animation)
{
super.onAnimationEnd(animation);
final View target = getTarget();
if (target != null)
{
target.setAlpha(1.0f);
target.setRotation(0.0f);
target.setRotationX(0.0f);
target.setRotationY(0.0f);
target.setTranslationX(0.0f);
target.setTranslationY(0.0f);
target.setScaleX(1.0f);
target.setScaleY(1.0f);
}
}
示例6: onTransform
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
final float rotation = -180f * position;
view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(view.getHeight() * 0.5f);
view.setRotationX(rotation);
}
示例7: clearAnimation
import android.view.View; //导入方法依赖的package包/类
public static void clearAnimation(View view) {
view.setAlpha(1);
view.setScaleX(1);
view.setScaleY(1);
view.setTranslationX(0);
view.setTranslationY(0);
view.setRotation(0);
view.setRotationX(0);
view.setRotationY(0);
}
示例8: setRotationX
import android.view.View; //导入方法依赖的package包/类
public void setRotationX(View view, float rotationX) {
if (View10.NEED_PROXY) {
View10.wrap(view).setRotationX(rotationX);
} else {
view.setRotationX(rotationX);
}
}
示例9: resetTransformProperty
import android.view.View; //导入方法依赖的package包/类
private static void resetTransformProperty(View view) {
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
view.setRotation(0);
view.setRotationX(0);
view.setRotationY(0);
view.setScaleX(1);
view.setScaleY(1);
view.setCameraDistance(0);
}
示例10: updateViewWithPercent
import android.view.View; //导入方法依赖的package包/类
/** 更新View */
public void updateViewWithPercent(View child, float percent) {
if (mAnimation == null) {
//如果没有自定义动画,那么使用属性动画
float newX = targetX == UNSPECIFIED_INT ? 0 : (targetX - mStartX) * percent;
float newY = targetY == UNSPECIFIED_INT ? 0 : (targetY - mStartY) * percent;
//缩放动画
if (targetWidth != UNSPECIFIED_INT || targetHeight != UNSPECIFIED_INT) {
child.setScaleX(scaleEvaluator(mStartWidth, targetWidth, percent));
child.setScaleY(scaleEvaluator(mStartHeight, targetHeight, percent));
float newWidth = floatEvaluator(mStartWidth, targetWidth, percent);
float newHeight = floatEvaluator(mStartWidth, targetWidth, percent);
newX -= (mStartWidth - newWidth) / 2;
newY -= (mStartHeight - newHeight) / 2;
}
//平移动画
child.setTranslationX(newX);
child.setTranslationY(newY);
//透明度变化
if (targetAlpha != UNSPECIFIED_FLOAT) child.setAlpha(floatEvaluator(mStartAlpha, targetAlpha, percent));
//背景渐变
if (targetBackgroundColor != UNSPECIFIED_INT && mStartBackgroundColor != 0) {
child.setBackgroundColor(argbEvaluator(mStartBackgroundColor, targetBackgroundColor, percent));
}
//旋转动画
if (targetRotateX != UNSPECIFIED_FLOAT) child.setRotationX(floatEvaluator(mStartRotateX, targetRotateX, percent));
if (targetRotateY != UNSPECIFIED_FLOAT) child.setRotationY(floatEvaluator(mStartRotateY, targetRotateY, percent));
} else {
mAnimation.setStartTime(0);
mAnimation.restrictDuration(100);
Transformation transformation = new Transformation();
mAnimation.getTransformation((long) (percent * 100), transformation);
BehaviorAnimation animation = new BehaviorAnimation(transformation);
child.startAnimation(animation);
}
child.requestLayout();
}
示例11: setValue
import android.view.View; //导入方法依赖的package包/类
/**
* This method handles setting the property values directly in the View object's fields.
* propertyConstant tells it which property should be set, value is the value to set
* the property to.
*
* @param propertyConstant The property to be set
* @param value The value to set the property to
*/
private void setValue(int propertyConstant, float value) {
//final View.TransformationInfo info = mView.mTransformationInfo;
View v = mView.get();
if (v != null) {
switch (propertyConstant) {
case TRANSLATION_X:
//info.mTranslationX = value;
v.setTranslationX(value);
break;
case TRANSLATION_Y:
//info.mTranslationY = value;
v.setTranslationY(value);
break;
case ROTATION:
//info.mRotation = value;
v.setRotation(value);
break;
case ROTATION_X:
//info.mRotationX = value;
v.setRotationX(value);
break;
case ROTATION_Y:
//info.mRotationY = value;
v.setRotationY(value);
break;
case SCALE_X:
//info.mScaleX = value;
v.setScaleX(value);
break;
case SCALE_Y:
//info.mScaleY = value;
v.setScaleY(value);
break;
case X:
//info.mTranslationX = value - v.mLeft;
v.setX(value);
break;
case Y:
//info.mTranslationY = value - v.mTop;
v.setY(value);
break;
case ALPHA:
//info.mAlpha = value;
v.setAlpha(value);
break;
}
}
}
示例12: setValue
import android.view.View; //导入方法依赖的package包/类
@Override
public void setValue(View target, float value) {
target.setRotationX(value);
}
示例13: drawChild
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean drawChild(Canvas canvas, View child, long drawingTime) {
// rotateX
int centerY = getVerticalSpace() / 2;
int childCenterY = child.getTop() + child.getHeight() / 2;
float factor = (centerY - childCenterY) * 1f / centerY;
float alphaFactor = 1 - 0.7f * Math.abs(factor);
child.setAlpha(alphaFactor * alphaFactor * alphaFactor);
float scaleFactor = 1 - 0.3f * Math.abs(factor);
child.setScaleX(scaleFactor);
child.setScaleY(scaleFactor);
float rotateRadius = 2.0f * centerY / (float) Math.PI;
float rad = (centerY - childCenterY) * 1f / rotateRadius;
float offsetZ = rotateRadius * (1 - (float) Math.cos(rad));
float rotateDeg = rad * 180 / (float) Math.PI;
ViewCompat.setZ(child, -offsetZ);
child.setRotationX(rotateDeg);
float offsetY = centerY - childCenterY - rotateRadius * (float) Math.sin(rad) * 1.3f;
child.setTranslationY(offsetY);
// resize the text size if text can not be shown completely
if (child instanceof TextView) {
String data = ((TextView) child).getText().toString();
if (((TextView) child).getTextSize() == mTextSize) {
float finalTextSize = mTextSize;
float dataStringW = StaticLayout.getDesiredWidth(data, 0, data.length(), ((TextView) child).getPaint());
if (getHorizontalSpace() > 0 && dataStringW * 1.1f > getHorizontalSpace()) {
finalTextSize = getHorizontalSpace() / dataStringW / 1.1f * mTextSize;
}
((TextView) child).setTextSize(TypedValue.COMPLEX_UNIT_PX, finalTextSize);
}
}
return super.drawChild(canvas, child, drawingTime);
// // parent centerY ,item centerY
// int centerY = (getHeight() - getPaddingTop() - getPaddingBottom()) / 2;
// int childCenterY = child.getTop() + child.getHeight() / 2;
// // alpha
// float factor = (centerY - childCenterY) * 1f / centerY;
// float currentFactor = 1 - 0.7f * Math.abs(factor);
// child.setAlpha(currentFactor * currentFactor * currentFactor);
//
// // rotate radius
// float rotateRadius = 2.5f * centerY / (float) Math.PI;
// // deg
// float rad = (centerY - childCenterY) * 1f / rotateRadius;
// float rotateDeg = rad * 180 / (float) Math.PI;
// // for camera
// float offsetZ = rotateRadius * (1 - (float) Math.cos(rad));
// canvas.save();
// // offset Y for item rotate
// float offsetY = centerY - childCenterY - rotateRadius * (float) Math.sin(rad);
// canvas.translate(0, offsetY);
// mCamera.save();
// mCamera.translate(0, 0, offsetZ);
// mCamera.rotateX(rotateDeg);
// mCamera.getMatrix(mMatrix);
// mCamera.restore();
// mMatrix.preTranslate(-child.getWidth() / 2, -childCenterY);
// mMatrix.postTranslate(child.getWidth() / 2, childCenterY);
// canvas.concat(mMatrix);
// super.drawChild(canvas, child, drawingTime);
// canvas.restore();
// return true;
}
示例14: setRotationX
import android.view.View; //导入方法依赖的package包/类
public static void setRotationX(View view, float value) {
view.setRotationX(value);
}