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

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

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

ImageButton.setElevation介绍

暂无

代码示例

代码示例来源:origin: Clans/FloatingActionButton

@Override
public void setElevation(float elevation) {
  if (Util.hasLollipop() && elevation > 0) {
    super.setElevation(elevation);
    if (!isInEditMode()) {
      mUsingElevation = true;
      mShowShadow = false;
    }
    updateBackground();
  }
}

代码示例来源:origin: Clans/FloatingActionButton

/**
 * Sets the shadow color and radius to mimic the native elevation.
 *
 * <p><b>API 21+</b>: Sets the native elevation of this view, in pixels. Updates margins to
 * make the view hold its position in layout across different platform versions.</p>
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setElevationCompat(float elevation) {
  mShadowColor = 0x26000000;
  mShadowRadius = Math.round(elevation / 2);
  mShadowXOffset = 0;
  mShadowYOffset = Math.round(mFabSize == SIZE_NORMAL ? elevation : elevation / 2);
  if (Util.hasLollipop()) {
    super.setElevation(elevation);
    mUsingElevationCompat = true;
    mShowShadow = false;
    updateBackground();
    ViewGroup.LayoutParams layoutParams = getLayoutParams();
    if (layoutParams != null) {
      setLayoutParams(layoutParams);
    }
  } else {
    mShowShadow = true;
    updateBackground();
  }
}

代码示例来源:origin: Meiqia/MeiqiaSDK-Android

@Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
    // 向服务器发送一个正在输入的函数
    if (!TextUtils.isEmpty(s)) {
      inputting(s.toString());
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mSendTextBtn.setElevation(MQUtils.dip2px(MQConversationActivity.this, 3));
      }
      mSendTextBtn.setImageResource(R.drawable.mq_ic_send_icon_white);
      mSendTextBtn.setBackgroundResource(R.drawable.mq_shape_send_back_pressed);
    } else {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mSendTextBtn.setElevation(0);
      }
      mSendTextBtn.setImageResource(R.drawable.mq_ic_send_icon_grey);
      mSendTextBtn.setBackgroundResource(R.drawable.mq_shape_send_back_normal);
    }
  }
};

代码示例来源:origin: douzifly/clear-todolist

@Override
public void setElevation(float elevation) {
  if (Util.hasLollipop() && elevation > 0) {
    super.setElevation(elevation);
    if (!isInEditMode()) {
      mUsingElevation = true;
      mShowShadow = false;
    }
    updateBackground();
  }
}

代码示例来源:origin: Blankeer/MDWechat

@Override
public void setElevation(float elevation) {
  if (Util.hasLollipop() && elevation > 0) {
    super.setElevation(elevation);
    if (!isInEditMode()) {
      mUsingElevation = true;
      mShowShadow = false;
    }
    updateBackground();
  }
}

代码示例来源:origin: Blankeer/MDWechat

/**
 * Sets the shadow color and radius to mimic the native elevation.
 *
 * <p><b>API 21+</b>: Sets the native elevation of this view, in pixels. Updates margins to
 * make the view hold its position in layout across different platform versions.</p>
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setElevationCompat(float elevation) {
  mShadowColor = 0x26000000;
  mShadowRadius = Math.round(elevation / 2);
  mShadowXOffset = 0;
  mShadowYOffset = Math.round(mFabSize == SIZE_NORMAL ? elevation : elevation / 2);
  if (Util.hasLollipop()) {
    super.setElevation(elevation);
    mUsingElevationCompat = true;
    mShowShadow = false;
    updateBackground();
    ViewGroup.LayoutParams layoutParams = getLayoutParams();
    if (layoutParams != null) {
      setLayoutParams(layoutParams);
    }
  } else {
    mShowShadow = true;
    updateBackground();
  }
}

代码示例来源:origin: douzifly/clear-todolist

/**
 * Sets the shadow color and radius to mimic the native elevation.
 *
 * <p><b>API 21+</b>: Sets the native elevation of this view, in pixels. Updates margins to
 * make the view hold its position in layout across different platform versions.</p>
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setElevationCompat(float elevation) {
  mShadowColor = 0x26000000;
  mShadowRadius = Math.round(elevation / 2);
  mShadowXOffset = 0;
  mShadowYOffset = Math.round(mFabSize == SIZE_NORMAL ? elevation : elevation / 2);
  if (Util.hasLollipop()) {
    super.setElevation(elevation);
    mUsingElevationCompat = true;
    mShowShadow = false;
    updateBackground();
    ViewGroup.LayoutParams layoutParams = getLayoutParams();
    if (layoutParams != null) {
      setLayoutParams(layoutParams);
    }
  } else {
    mShowShadow = true;
    updateBackground();
  }
}

相关文章

ImageButton类方法