本文整理汇总了Java中android.support.v4.view.ViewCompat.setX方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setX方法的具体用法?Java ViewCompat.setX怎么用?Java ViewCompat.setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.setX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setX
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void setX(final @NonNull View v, final int x) {
if (VERSION.SDK_INT >= 11) {
ViewCompat.setX(v, x);
} else {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)v.getLayoutParams();
params.leftMargin = x;
v.setLayoutParams(params);
}
}
示例2: updateSlideOffset
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateSlideOffset(View drawerView, float slideOffset) {
final int absHorizGravity = getDrawerViewAbsoluteGravity(Gravity.START);
final int childAbsGravity = getDrawerViewAbsoluteGravity(drawerView);
for (int i = 0; i < frameLayout.getChildCount(); i++) {
CardView child = (CardView) frameLayout.getChildAt(i);
Setting setting = settings.get(childAbsGravity);
float adjust = 0;
if (setting != null) {
child.setRadius((int) (setting.radius * slideOffset));
super.setScrimColor(setting.scrimColor);
super.setDrawerElevation(setting.drawerElevation);
float percentage = 1f - setting.percentage;
float reduceHeight = getHeight() * percentage * slideOffset;
FrameLayout.LayoutParams params
= (FrameLayout.LayoutParams) child.getLayoutParams();
params.topMargin = (int) (reduceHeight / 2);
params.bottomMargin = (int) (reduceHeight / 2);
child.setLayoutParams(params);
child.setCardElevation(setting.elevation * slideOffset);
adjust = setting.elevation;
float width = childAbsGravity == absHorizGravity ?
drawerView.getWidth() + adjust : -drawerView.getWidth() - adjust;
ViewCompat.setX(child, width * slideOffset);
} else {
super.setScrimColor(defaultScrimColor);
super.setDrawerElevation(defaultDrawerElevation);
}
}
}
示例3: updateMaxValue
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static void updateMaxValue(final View targetView,
final float startScaleX, final float startScaleY,
final Point startPoint,
final Point endPoint,
float fraction) {
ViewCompat.setScaleX(targetView, startScaleX + (1 - startScaleX) * fraction);
ViewCompat.setScaleY(targetView, startScaleY + (1 - startScaleY) * fraction);
ViewCompat.setX(targetView, (startPoint.x + (endPoint.x - startPoint.x) * fraction) - targetView.getMeasuredWidth() / 2);
ViewCompat.setY(targetView, (startPoint.y + (endPoint.y - startPoint.y) * fraction) - targetView.getMeasuredHeight() / 2);
}
示例4: applyTailEffect
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void applyTailEffect(@NonNull ViewGroup vg, @NonNull TransformParams params) {
final float position = params.position;
final float floorDiff = params.floorDiff;
if (position < -1 || position > 1) {
for (int i = 0, cnt = vg.getChildCount(); i < cnt; i++) {
ViewCompat.setX(vg.getChildAt(i), 0);
}
return;
}
final View firstOffsetChild = vg.getChildAt(vg.getChildCount() - 1);
float sign;
final float childX = ViewCompat.getX(firstOffsetChild);
if (floorDiff > 0.5f) {
if (childX < -10){
sign = -1;
} else {
sign = 1;
}
} else {
if (childX > 10) {
sign = 1;
} else {
sign = -1;
}
}
for (int i = 0, j = 1, cnt = vg.getChildCount(); i < cnt; i++) {
final View child = vg.getChildAt(i);
final boolean isHeaderView = (Boolean) child.getTag(R.id.tail_header_tag);
if (isHeaderView) {
continue;
}
final float childOffset;
if (floorDiff > 0.5f) {
childOffset = (1f - floorDiff) * OFFSET_MAX * j;
} else {
childOffset = floorDiff * OFFSET_MAX * j;
}
ViewCompat.setX(child, sign * childOffset);
j++;
}
}