本文整理汇总了Java中android.view.View.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java View.setRotation方法的具体用法?Java View.setRotation怎么用?Java View.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setRotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: rotate
import android.view.View; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
public void rotate(@NonNull View view, @IntRange(from = 0, to = 359) int rotation) {
if (!ready()) {
requestedRotation = rotation;
requestedModificationView = new WeakReference<>(view);
return;
}
boolean swapWidthHeight = ((rotation / QUARTER_ROTATION) % 2) == 1;
boolean currentWidthHeightSwapped = ((currentRotation / QUARTER_ROTATION) % 2) == 1;
//Makes sure the width and height are correctly swapped
if (swapWidthHeight != currentWidthHeightSwapped) {
int tempX = intrinsicVideoSize.x;
intrinsicVideoSize.x = intrinsicVideoSize.y;
intrinsicVideoSize.y = tempX;
//We re-apply the scale to make sure it is correct
scale(view, currentScaleType);
}
currentRotation = rotation;
view.setRotation(rotation);
}
示例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: updateWobbleState
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void updateWobbleState(int visibleItemCount) {
for (int i = 0; i < visibleItemCount; i++) {
View child = getChildAt(i);
if (child != null) {
if (mMobileItemId != INVALID_ID && Boolean.TRUE != child.getTag(R.id.wobble_tag)) {
if (i % 2 == 0)
animateWobble(child);
else
animateWobbleInverse(child);
child.setTag(R.id.wobble_tag, true);
} else if (mMobileItemId == INVALID_ID && child.getRotation() != 0) {
child.setRotation(0);
child.setTag(R.id.wobble_tag, false);
}
}
}
}
示例5: setChildRotationHorizontal
import android.view.View; //导入方法依赖的package包/类
/**
* Given that the orientation is {@link Orientation#HORIZONTAL}, apply rotation if enabled.
*/
private void setChildRotationHorizontal(@Gravity int gravity, View child, int radius, Point center) {
if (!rotate) {
child.setRotation(0);
return;
}
boolean childPastCenter = (child.getX() + child.getWidth() / 2) > center.x;
float directionMult;
if (gravity == Gravity.END) {
directionMult = childPastCenter ? 1 : -1;
} else {
directionMult = childPastCenter ? -1 : 1;
}
final float opposite = Math.abs(child.getX() + child.getWidth() / 2 - center.x);
child.setRotation((float) (directionMult * Math.toDegrees(Math.asin(opposite / radius))));
}
示例6: createShowItemAnimator
import android.view.View; //导入方法依赖的package包/类
private Animator createShowItemAnimator(View item) {
float dx = fab.getX() - item.getX();
float dy = fab.getY() - item.getY();
item.setRotation(0f);
item.setTranslationX(dx);
item.setTranslationY(dy);
Animator anim = ObjectAnimator.ofPropertyValuesHolder(
item,
AnimatorUtils.rotation(0f, 720f),
AnimatorUtils.translationX(dx, 0f),
AnimatorUtils.translationY(dy, 0f)
);
return anim;
}
示例7: setViewLocation
import android.view.View; //导入方法依赖的package包/类
private void setViewLocation(float percentage) {
final int windowWidth = getWidth();
final int halfWindowWidth = windowWidth / 2;
final int radius = (int)Math.round(halfWindowWidth / Math.sin(Math.toRadians(mDegreeUnit)));
final float HORIZON_SCALE = 1.1f;
for(int i = 0; i < mReusableViews.size(); i++) {
View view = mReusableViews.get(i);
float degree = mDegreeUnit * i - mDegreeUnit * percentage;
int threshold = mDegreeUnit * (mReusableViews.size() - 1);
while(Math.abs(degree) >= threshold) {
if(degree < 0)
degree += (mReusableViews.size())* mDegreeUnit;
else
degree -= (mReusableViews.size()) * mDegreeUnit;
}
view.setRotation(degree);
int left = (int)Math.round(
halfWindowWidth + HORIZON_SCALE * radius * Math.sin(Math.toRadians(degree)) - mItemViewWidth / 2
);
int bottom = (int)Math.round(
radius * Math.cos(Math.toRadians(degree)) - radius * Math.cos(Math.toRadians(mDegreeUnit))
);
view.setTranslationX(left);
view.setTranslationY(-bottom);
//Log.d("setting", String.format("(%d) degree: %.4f, position: (%d, %d)", i, degree, left, bottom));
}
}
示例8: setItemViewProperty
import android.view.View; //导入方法依赖的package包/类
@Override
protected void setItemViewProperty(View itemView, float targetOffset) {
itemView.setRotation(targetOffset);
float scale = calculateScale(itemView,targetOffset);
itemView.setScaleX(scale);
itemView.setScaleY(scale);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
itemView.setZ(scale);
}
}
示例9: onTransform
import android.view.View; //导入方法依赖的package包/类
@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;
view.setPivotX(width * 0.5f);
view.setPivotY(height);
view.setRotation(rotation);
}
示例10: restoreView
import android.view.View; //导入方法依赖的package包/类
private void restoreView(View v) {
v.setVisibility(endVisibility);
v.setPivotY(v.getHeight() / 2);
v.setPivotX(v.getWidth() / 2);
v.setRotation(0);
v.setRotationX(0);
v.setRotationY(0);
v.setTranslationX(0);
v.setTranslationY(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
v.setTranslationZ(0);
}
}
示例11: render
import android.view.View; //导入方法依赖的package包/类
@Override
public void render(CoachmarkViewLayout layout, View actionDescription, View actionArrow) {
RectF circleRectangle = layout.calcCircleRectF();
actionDescription.setX((int) (circleRectangle.right + actionArrow.getWidth()));
actionDescription.setY(circleRectangle.centerY() - (actionDescription.getHeight() / 2));
actionArrow.setRotation(180);
actionArrow.setX(circleRectangle.right);
actionArrow.setY(circleRectangle.centerY() - (actionArrow.getHeight() / 2));
}
示例12: render
import android.view.View; //导入方法依赖的package包/类
@Override
public void render(CoachmarkViewLayout layout, View actionDescription, View actionArrow) {
RectF circleRectangle = layout.calcCircleRectF();
actionDescription.setX(circleRectangle.centerX() - (actionDescription.getWidth() / 2));
actionDescription.setY(circleRectangle.top - actionArrow.getHeight() - actionDescription.getHeight());
actionArrow.setRotation(90);
actionArrow.setX(circleRectangle.centerX() - (actionArrow.getWidth() / 2));
actionArrow.setY(circleRectangle.top - actionArrow.getHeight());
}
示例13: move
import android.view.View; //导入方法依赖的package包/类
private static void move(View view, TransformInfo info) {
computeRenderOffset(view, info.pivotX, info.pivotY);
adjustTranslation(view, info.deltaX, info.deltaY);
float scale = view.getScaleX() * info.deltaScale;
scale = Math.max(info.minimumScale, Math.min(info.maximumScale, scale));
view.setScaleX(scale);
view.setScaleY(scale);
float rotation = adjustAngle(view.getRotation() + info.deltaAngle);
view.setRotation(rotation);
}
示例14: rotateView
import android.view.View; //导入方法依赖的package包/类
public static void rotateView(View view,float fromDegree,float toDegree){
if (Build.VERSION.SDK_INT < 11) {
RotateAnimation animation = new RotateAnimation(fromDegree, toDegree, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(100);
animation.setFillAfter(true);
view.startAnimation(animation);
} else {
view.setRotation(toDegree);
}
}
示例15: setRotation
import android.view.View; //导入方法依赖的package包/类
public static void setRotation(View view, float rotation) {
if (View10.NEED_PROXY) {
View10.wrap(view).setRotation(rotation);
} else {
view.setRotation(rotation);
}
}