下面列出了android.support.v4.view.ViewCompat#setRotation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void resetPageTransformer(List<? extends View> views) {
if (views == null) {
return;
}
for (View view : views) {
view.setVisibility(View.VISIBLE);
ViewCompat.setAlpha(view, 1);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
}
}
public static void resetPageTransformer(List<? extends View> views) {
if (views == null) {
return;
}
for (View view : views) {
view.setVisibility(View.VISIBLE);
ViewCompat.setAlpha(view, 1);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
}
}
public static void resetPageTransformer(List<? extends View> views) {
if (views == null) {
return;
}
for (View view : views) {
view.setVisibility(View.VISIBLE);
ViewCompat.setAlpha(view, 1);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
}
}
public static void resetPageTransformer(List<? extends View> views) {
if (views == null) {
return;
}
for (View view : views) {
view.setVisibility(View.VISIBLE);
ViewCompat.setAlpha(view, 1);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
}
}
@Override
protected void onTransform(View view, float position) {
final float width = view.getWidth();
final float height = view.getHeight();
final float rotation = ROT_MOD * position * -1.25f;
ViewCompat.setPivotX(view, width * 0.5f);
ViewCompat.setPivotY(view,height);
ViewCompat.setRotation(view,rotation);
}
public static void clear(View v) {
ViewCompat.setAlpha(v, 1);
ViewCompat.setScaleY(v, 1);
ViewCompat.setScaleX(v, 1);
ViewCompat.setTranslationY(v, 0);
ViewCompat.setTranslationX(v, 0);
ViewCompat.setRotation(v, 0);
ViewCompat.setRotationY(v, 0);
ViewCompat.setRotationX(v, 0);
// @TODO https://code.google.com/p/android/issues/detail?id=80863
// ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
/**
* reset the view to default status
*
* @param target
*/
public void reset(View target) {
ViewCompat.setAlpha(target, 1);
ViewCompat.setScaleX(target, 1);
ViewCompat.setScaleY(target, 1);
ViewCompat.setTranslationX(target, 0);
ViewCompat.setTranslationY(target, 0);
ViewCompat.setRotation(target, 0);
ViewCompat.setRotationY(target, 0);
ViewCompat.setRotationX(target, 0);
}
@Override
public void handleLeftPage(View view, float position) {
float rotation = (mMaxRotation * position);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight());
ViewCompat.setRotation(view, rotation);
}
@Override
protected void onTransform(View view, float position) {
final float width = view.getWidth();
final float rotation = ROT_MOD * position;
ViewCompat.setPivotX(view, width * 0.5f);
ViewCompat.setPivotY(view,0f);
ViewCompat.setTranslationX(view,0f);
ViewCompat.setRotation(view,rotation);
}
@Override
protected void onTransform(View view, float position) {
// Rotate the fragment on the left or right edge
ViewCompat.setPivotX(view,position > 0 ? 0 : view.getWidth());
ViewCompat.setPivotY(view,0);
ViewCompat.setRotation(view, -90f * position);
}
public static void clear(View v) {
ViewCompat.setAlpha(v, 1);
ViewCompat.setScaleY(v, 1);
ViewCompat.setScaleX(v, 1);
ViewCompat.setTranslationY(v, 0);
ViewCompat.setTranslationX(v, 0);
ViewCompat.setRotation(v, 0);
ViewCompat.setRotationY(v, 0);
ViewCompat.setRotationX(v, 0);
ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null).setStartDelay(0);
}
public static void clear(View v) {
ViewCompat.setAlpha(v, 1);
ViewCompat.setScaleY(v, 1);
ViewCompat.setScaleX(v, 1);
ViewCompat.setTranslationY(v, 0);
ViewCompat.setTranslationX(v, 0);
ViewCompat.setRotation(v, 0);
ViewCompat.setRotationY(v, 0);
ViewCompat.setRotationX(v, 0);
v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
public static void clear(View v) {
ViewCompat.setAlpha(v, 1);
ViewCompat.setScaleY(v, 1);
ViewCompat.setScaleX(v, 1);
ViewCompat.setTranslationY(v, 0);
ViewCompat.setTranslationX(v, 0);
ViewCompat.setRotation(v, 0);
ViewCompat.setRotationY(v, 0);
ViewCompat.setRotationX(v, 0);
v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
public static void clear(View v) {
ViewCompat.setAlpha(v, 1);
ViewCompat.setScaleY(v, 1);
ViewCompat.setScaleX(v, 1);
ViewCompat.setTranslationY(v, 0);
ViewCompat.setTranslationX(v, 0);
ViewCompat.setRotation(v, 0);
ViewCompat.setRotationY(v, 0);
ViewCompat.setRotationX(v, 0);
// @TODO https://code.google.com/p/android/issues/detail?id=80863
ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
// v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
@Override
public void handleInvisiblePage(View view, float position) {
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight());
ViewCompat.setRotation(view, 0);
}
@Override
public void handleInvisiblePage(View view, float position) {
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight());
ViewCompat.setRotation(view, 0);
}
public void rotateByValue(float rotateOffset, boolean reverse) {
if (reverse)
rotateOffset = 360f - rotateOffset;
ViewCompat.setRotation(this, rotateOffset);
}
@Override
public void onPositionChange(float currentPercent) {
float rotation = currentPercent * 360;
if (rotation >= 360) {
rotation = 360;
}
float distance = currentPercent * MAX_DISTANCE;
if (distance >= MAX_DISTANCE) {
distance = MAX_DISTANCE;
}
ViewCompat.setRotation(mShapeLoadingView, rotation);
ViewCompat.setTranslationY(mShapeLoadingView, distance);
}
/**
* Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
*
* @param view view
* @param position position
*/
protected void onPreTransform(View view, float position) {
final float width = view.getWidth();
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setPivotX(view, 0);
ViewCompat.setPivotY(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setTranslationX(view, isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
ViewCompat.setAlpha(view, position <= -1f || position >= 1f ? 0f : 1f);
} else {
ViewCompat.setAlpha(view, 1f);
}
if (mCustomAnimationInterface != null) {
if (h.containsKey(view) == false || h.get(view).size() == 1) {
if (position > -1 && position < 1) {
if (h.get(view) == null) {
h.put(view, new ArrayList<Float>());
}
h.get(view).add(position);
if (h.get(view).size() == 2) {
float zero = h.get(view).get(0);
float cha = h.get(view).get(1) - h.get(view).get(0);
if (zero > 0) {
if (cha > -1 && cha < 0) {
//in
mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
} else {
//out
mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
}
} else {
if (cha > -1 && cha < 0) {
//out
mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
} else {
//in
mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
}
}
}
}
}
}
}
@Override
public void onPositionChange(float currentPercent) {
ViewCompat.setRotation(ivRotate,currentPercent*rotateHight);
}