當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。