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


Java ShapeDrawable.setShape方法代码示例

本文整理汇总了Java中android.graphics.drawable.ShapeDrawable.setShape方法的典型用法代码示例。如果您正苦于以下问题:Java ShapeDrawable.setShape方法的具体用法?Java ShapeDrawable.setShape怎么用?Java ShapeDrawable.setShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.ShapeDrawable的用法示例。


在下文中一共展示了ShapeDrawable.setShape方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCornerDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public static Drawable getCornerDrawable(float topLeft,
                                         float topRight,
                                         float bottomLeft,
                                         float bottomRight,
                                          @ColorInt int color) {

    float[] outerR = new float[8];
    outerR[0] = topLeft;
    outerR[1] = topLeft;
    outerR[2] = topRight;
    outerR[3] = topRight;
    outerR[4] = bottomRight;
    outerR[5] = bottomRight;
    outerR[6] = bottomLeft;
    outerR[7] = bottomLeft;

    ShapeDrawable drawable = new ShapeDrawable();
    drawable.setShape(new RoundRectShape(outerR, null, null));
    drawable.getPaint().setColor(color);

    return drawable;
}
 
开发者ID:apg-mobile,项目名称:android-round-textview,代码行数:23,代码来源:DrawableHelper.java

示例2: createProductImageDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private Drawable createProductImageDrawable(Product product) {
    final ShapeDrawable background = new ShapeDrawable();
    background.setShape(new OvalShape());
    background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color));

    final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
            BitmapFactory.decodeResource(getResources(), product.image));

    final LayerDrawable layerDrawable = new LayerDrawable
            (new Drawable[]{background, bitmapDrawable});

    final int padding = (int) getResources().getDimension(R.dimen.spacing_huge);
    layerDrawable.setLayerInset(1, padding, padding, padding, padding);

    return layerDrawable;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:17,代码来源:OrderDialogFragment.java

示例3: getBackground

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private static Drawable getBackground(int normalStateColor,
    int pressedStateColor) {
  StateListDrawable background = new StateListDrawable();
  int c = SizeUtil.dp10;
  float[] r = new float[] {c, c, c, c, c, c, c, c};
  RoundRectShape rr = new RoundRectShape(r, null, null);
  ShapeDrawable cd = new ShapeDrawable();
  cd.setShape(rr);
  cd.getPaint().setColor(pressedStateColor);
  background.addState(new int[] {android.R.attr.state_pressed,
      android.R.attr.state_focused}, cd);
  background.addState(new int[] {-android.R.attr.state_pressed,
      android.R.attr.state_focused}, cd);
  background.addState(new int[] {android.R.attr.state_pressed,
      -android.R.attr.state_focused}, cd);
  ShapeDrawable cd1 = new ShapeDrawable();
  cd1.setShape(rr);
  cd1.getPaint().setColor(normalStateColor);
  background.addState(new int[] {-android.R.attr.state_pressed,
      -android.R.attr.state_focused}, cd1);
  return background;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:23,代码来源:BitmapUtil.java

示例4: createBackgroundImageView

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private ImageView createBackgroundImageView(Context context, boolean fullscreen) {
  BackgroundImageView view = new BackgroundImageView(context, fullscreen);
  view.setScaleType(ImageView.ScaleType.CENTER_CROP);
  int cornerRadius;
  if (!fullscreen) {
    cornerRadius = SizeUtil.dp20;
  } else {
    cornerRadius = 0;
  }
  view.setImageBitmap(options.getBackgroundImage());
  ShapeDrawable footerBackground = new ShapeDrawable();
  footerBackground.setShape(createRoundRect(cornerRadius));
  footerBackground.getPaint().setColor(options.getBackgroundColor());
  if (Build.VERSION.SDK_INT >= 16) {
    view.setBackground(footerBackground);
  } else {
    view.setBackgroundDrawable(footerBackground);
  }
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  view.setLayoutParams(layoutParams);
  return view;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:25,代码来源:BaseMessageDialog.java

示例5: createProductImageDrawable

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private Drawable createProductImageDrawable(Product product) {
    final ShapeDrawable background = new ShapeDrawable();
    background.setShape(new OvalShape());
    background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color));

    final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
        BitmapFactory.decodeResource(getResources(), product.image));

    final LayerDrawable layerDrawable = new LayerDrawable
        (new Drawable[]{background, bitmapDrawable});

    final int padding = (int) getResources().getDimension(R.dimen.spacing_huge);
    layerDrawable.setLayerInset(1, padding, padding, padding, padding);

    return layerDrawable;
}
 
开发者ID:saulmm,项目名称:From-design-to-Android-part1,代码行数:17,代码来源:OrderDialogFragment.java

示例6: setShape

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void setShape() {
  ShapeDrawable drawable = new ShapeDrawable();
  // Set color of drawable.
  drawable.getPaint().setColor((backgroundColor == Component.COLOR_DEFAULT)
                               ? SHAPED_DEFAULT_BACKGROUND_COLOR : backgroundColor);
  // Set shape of drawable.
  switch (shape) {
    case Component.BUTTON_SHAPE_ROUNDED:
      drawable.setShape(new RoundRectShape(ROUNDED_CORNERS_ARRAY, null, null));
      break;
    case Component.BUTTON_SHAPE_RECT:
      drawable.setShape(new RectShape());
      break;
    case Component.BUTTON_SHAPE_OVAL:
      drawable.setShape(new OvalShape());
      break;
    default:
      throw new IllegalArgumentException();
  }
  // Set drawable to the background of the button.
  view.setBackgroundDrawable(drawable);
  view.invalidate();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:24,代码来源:ButtonBase.java


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