android.widget.ImageView.setElevation()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中android.widget.ImageView.setElevation()方法的一些代码示例,展示了ImageView.setElevation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setElevation()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setElevation

ImageView.setElevation介绍

暂无

代码示例

代码示例来源:origin: ZieIony/Carbon

@Override
public void setElevation(float elevation) {
  if (Carbon.IS_PIE_OR_HIGHER) {
    super.setElevation(elevation);
    super.setTranslationZ(translationZ);
  } else if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
    if ((ambientShadowColor == null || spotShadowColor == null) && renderingMode == RenderingMode.Auto) {
      super.setElevation(elevation);
      super.setTranslationZ(translationZ);
    } else {
      super.setElevation(0);
      super.setTranslationZ(0);
    }
  } else if (elevation != this.elevation && getParent() != null) {
    ((View) getParent()).postInvalidate();
  }
  this.elevation = elevation;
}

代码示例来源:origin: Luolc/EmojiRain

private ImageView generateEmoji(Drawable emojiDrawable) {
  ImageView emoji = new ImageView(getContext());
  emoji.setImageDrawable(emojiDrawable);
  final int width = (int) (EMOJI_STANDARD_SIZE * (1.0 + Randoms.positiveGaussian()));
  final int height = (int) (EMOJI_STANDARD_SIZE * (1.0 + Randoms.positiveGaussian()));
  final LayoutParams params = new LayoutParams(width, height);
  params.getPercentLayoutInfo().leftMarginPercent = Randoms.floatStandard();
  params.topMargin = -height;
  params.leftMargin = ((int) (-0.5F * width));
  emoji.setLayoutParams(params);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    emoji.setElevation(100);
  }
  return emoji;
}

相关文章

ImageView类方法