• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BorderDrawable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.taobao.weex.ui.view.border.BorderDrawable的典型用法代码示例。如果您正苦于以下问题:Java BorderDrawable类的具体用法?Java BorderDrawable怎么用?Java BorderDrawable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BorderDrawable类属于com.taobao.weex.ui.view.border包,在下文中一共展示了BorderDrawable类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBorderDrawable

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public static @Nullable
BorderDrawable getBorderDrawable(@NonNull View view){
  Drawable drawable=view.getBackground();
  if(drawable instanceof BorderDrawable){
    return (BorderDrawable) drawable;
  }
  else if(drawable instanceof LayerDrawable){
    if(((LayerDrawable) drawable).getNumberOfLayers()>1) {
      Drawable innerDrawable=((LayerDrawable) drawable).getDrawable(0);
      if(innerDrawable instanceof BorderDrawable){
        return (BorderDrawable) innerDrawable;
      }
    }
  }
  return null;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:17,代码来源:WXViewUtils.java


示例2: setBorderRadius

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
  if (borderRadius >= 0) {
    switch (key) {
      case Constants.Name.BORDER_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius));
        break;
      case Constants.Name.BORDER_TOP_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
        break;
      case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
        break;
      case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
        break;
      case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius));
        break;
    }
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WXComponent.java


示例3: clipCanvasIfBackgroundImageExist

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
/**
 * Due limitation in Android platform, the linear gradient in the following page will not be
 * rounded if {@link Canvas#clipPath(Path)} of the parent view invoked when API level is lower
 * than 21.
 * http://dotwe.org/weex/963c9ade129f86757cecdd85651cd30e
 * @param targetView
 * @param borderDrawable
 * @return
 */
private static boolean clipCanvasIfBackgroundImageExist(@NonNull View targetView,
                                                        @NonNull BorderDrawable borderDrawable) {
  if (targetView instanceof ViewGroup) {
    View child;
    ViewGroup parent = ((ViewGroup) targetView);
    int count = parent.getChildCount();
    for (int i = 0; i < count; i++) {
      child = parent.getChildAt(i);
      if (child.getBackground() instanceof BorderDrawable &&
          ((BorderDrawable) child.getBackground()).hasImage() &&
          Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:27,代码来源:WXViewUtils.java


示例4: setBorderRadius

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
  if (borderRadius >= 0) {
    switch (key) {
      case Constants.Name.BORDER_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
        break;
      case Constants.Name.BORDER_TOP_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
        break;
      case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
        break;
      case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
        break;
      case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getInstanceViewPortWidth()));
        break;
    }
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:22,代码来源:WXComponent.java


示例5: clipCanvasWithinBorderBox

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public static void clipCanvasWithinBorderBox(View targetView, Canvas canvas) {
  Drawable drawable;
  /* According to https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported
    API 18 or higher supports clipPath to canvas based on hardware acceleration.
   */
  if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ||
       !canvas.isHardwareAccelerated()) &&
      ((drawable = targetView.getBackground()) instanceof BorderDrawable)) {
    BorderDrawable borderDrawable = (BorderDrawable) drawable;
    if(borderDrawable.isRounded()) {
      Path path = borderDrawable.getContentPath(
          new RectF(0, 0, targetView.getWidth(), targetView.getHeight()));
      canvas.clipPath(path);
    }
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:17,代码来源:WXViewUtils.java


示例6: setBorderRadius

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public void setBorderRadius(String key, float borderRadius) {
  if (borderRadius >= 0) {
    switch (key) {
      case Constants.Name.BORDER_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
        break;
      case Constants.Name.BORDER_TOP_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
        break;
      case Constants.Name.BORDER_TOP_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
        break;
      case Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
        break;
      case Constants.Name.BORDER_BOTTOM_LEFT_RADIUS:
        getOrCreateBorder().setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, WXViewUtils.getRealSubPxByWidth(borderRadius,mInstance.getViewPortWidth()));
        break;
    }
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:22,代码来源:WXComponent.java


示例7: createAnimator

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:52,代码来源:WXAnimationModule.java


示例8: testSetBackgroundColor

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
@Test
@PrepareForTest(WXImageView.class)
public void testSetBackgroundColor() throws Exception {

  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setBackgroundColor("#FFFFFF");

  Drawable drawable = mWXImage.getHostView().getBackground();
  assertEquals(drawable instanceof BorderDrawable, true);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:13,代码来源:WXImageTest.java


示例9: clipCanvasWithinBorderBox

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
public static void clipCanvasWithinBorderBox(View targetView, Canvas canvas) {
  Drawable drawable;
  if (clipCanvasDueToAndroidVersion(canvas) &&
      clipCanvasIfAnimationExist() &&
      ((drawable = targetView.getBackground()) instanceof BorderDrawable)) {
    BorderDrawable borderDrawable = (BorderDrawable) drawable;
    if (borderDrawable.isRounded()) {
      if (clipCanvasIfBackgroundImageExist(targetView, borderDrawable)) {
        Path path = borderDrawable.getContentPath(
            new RectF(0, 0, targetView.getWidth(), targetView.getHeight()));
        canvas.clipPath(path);
      }
    }
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:16,代码来源:WXViewUtils.java


示例10: get

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
@Override
public Integer get(View object) {
  int color;
  BorderDrawable borderDrawable;
  if ((borderDrawable = WXViewUtils.getBorderDrawable(object)) != null) {
    color = borderDrawable.getColor();
  } else if (object.getBackground() instanceof ColorDrawable) {
    color = ((ColorDrawable) object.getBackground()).getColor();
  } else {
    color = Color.TRANSPARENT;
    WXLogUtils.e(TAG, "Unsupported background type");
  }
  return color;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:15,代码来源:BackgroundColorProperty.java


示例11: set

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
@Override
public void set(View object, Integer value) {
  BorderDrawable borderDrawable;
  if ((borderDrawable = WXViewUtils.getBorderDrawable(object)) != null) {
    borderDrawable.setColor(value);
  } else if (object.getBackground() instanceof ColorDrawable) {
    ((ColorDrawable) object.getBackground()).setColor(value);
  } else {
    WXLogUtils.e(TAG, "Unsupported background type");
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:12,代码来源:BackgroundColorProperty.java


示例12: getBorderWidthNative

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
private static float getBorderWidthNative(@NonNull BorderDrawable drawable, int position) {
    try {
        Method method = drawable.getClass().getDeclaredMethod("getBorderWidth",int.class);
        method.setAccessible(true);
        return (float) method.invoke(drawable,position);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0f;
}
 
开发者ID:weexteam,项目名称:weex-analyzer-android,代码行数:11,代码来源:ViewPropertiesSupplier.java


示例13: getBorderColorNative

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
private static int getBorderColorNative(@NonNull BorderDrawable drawable, int position) {
    try {
        Method method = drawable.getClass().getDeclaredMethod("getBorderColor",int.class);
        method.setAccessible(true);
        return (int) method.invoke(drawable,position);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
 
开发者ID:weexteam,项目名称:weex-analyzer-android,代码行数:11,代码来源:ViewPropertiesSupplier.java


示例14: draw

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
@Override
public void draw(Canvas canvas) {
  Bitmap bitmap;
  if (mOriginal instanceof BitmapDrawable &&
      (bitmap = ((BitmapDrawable) mOriginal).getBitmap()) != null) {
    Path path;
    RectF bounds = new RectF(getBounds());
    BorderDrawable borderDrawable;
    if ((borderDrawable = WXViewUtils.getBorderDrawable(WXImageView.this)) != null) {
      path = borderDrawable.getContentPath(getPaddingTop(),
                                           getPaddingRight(),
                                           getPaddingBottom(),
                                           getPaddingLeft(),
                                           bounds);
    } else {
      path = new Path();
      path.addRect(bounds, Path.Direction.CW);
    }
    Matrix matrix = new Matrix();
    matrix.setScale(bounds.width() / bitmap.getWidth(),
                    bounds.height() / bitmap.getHeight());
    BitmapShader bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    bitmapShader.setLocalMatrix(matrix);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setShader(bitmapShader);
    canvas.drawPath(path, mPaint);
  } else {
    //TODO Not strictly clip according to background-clip:border-box
    mOriginal.draw(canvas);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:32,代码来源:WXImageView.java


示例15: createAnimator

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
private
@Nullable
ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
  if (target == null) {
    return null;
  }
  WXAnimationBean.Style style = mAnimationBean.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders = style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
        holders.add(PropertyValuesHolder.ofObject(
            new BackgroundColorProperty(), new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            new BackgroundColorProperty(), new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }

    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width,
            (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height,
            (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)));
      }
    }

    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(mAnimationBean.delay);
    return animator;
  } else {
    return null;
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:52,代码来源:AnimationAction.java


示例16: createAnimator

import com.taobao.weex.ui.view.border.BorderDrawable; //导入依赖的package包/类
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target,final int viewPortWidth) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width),viewPortWidth));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height),viewPortWidth));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:51,代码来源:WXAnimationModule.java



注:本文中的com.taobao.weex.ui.view.border.BorderDrawable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KeyValueTemplate类代码示例发布时间:2022-05-23
下一篇:
Java And类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap