当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.setX方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:10,代码来源:ViewUtil.java

示例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);
        }


    }

}
 
开发者ID:shiburagi,项目名称:Drawer-Behavior,代码行数:39,代码来源:AdvanceDrawerLayout.java

示例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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:12,代码来源:AnimUtil.java

示例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++;
    }
}
 
开发者ID:Ramotion,项目名称:garland-view-android,代码行数:50,代码来源:TailItemTransformer.java


注:本文中的android.support.v4.view.ViewCompat.setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。