com.coder.zzq.smartshow.core.Utils.dpToPx()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(153)

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

Utils.dpToPx介绍

暂无

代码示例

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
public void showAtLocation(CharSequence msg, int gravity, float xOffsetDp, float yOffsetDp) {
  int xOffset = Utils.dpToPx(xOffsetDp);
  int yOffset = Utils.dpToPx(yOffsetDp);
  showHelper(msg, gravity, xOffset, yOffset, Toast.LENGTH_SHORT);
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
public void showAtLocation(CharSequence msg, int gravity, float xOffsetDp, float yOffsetDp) {
  int xOffset = Utils.dpToPx(xOffsetDp);
  int yOffset = Utils.dpToPx(yOffsetDp);
  showHelper(msg, gravity, xOffset, yOffset, Toast.LENGTH_SHORT);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
public void showLongAtLocation(CharSequence msg, int gravity, float xOffsetDp, float yOffsetDp) {
  int xOffset = Utils.dpToPx(xOffsetDp);
  int yOffset = Utils.dpToPx(yOffsetDp);
  showHelper(msg, gravity, xOffset, yOffset, Toast.LENGTH_LONG);
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
public void showLongAtLocation(CharSequence msg, int gravity, float xOffsetDp, float yOffsetDp) {
  int xOffset = Utils.dpToPx(xOffsetDp);
  int yOffset = Utils.dpToPx(yOffsetDp);
  showHelper(msg, gravity, xOffset, yOffset, Toast.LENGTH_LONG);
}

代码示例来源:origin: the-pig-of-jungle/smart-show

protected int provideDialogWidth() {
  return Utils.screenWidth() - Utils.dpToPx(70);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

protected int provideDialogWidth() {
  return Utils.screenWidth() - Utils.dpToPx(70);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

public static int getStatusBarHeight() {
  int resourceId = SmartShow.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
  int height = 0;
  try {
    height = SmartShow.getContext().getResources().getDimensionPixelSize(resourceId);
  } catch (Resources.NotFoundException e) {
    height = Utils.dpToPx(24);
  }
  return height;
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

public static int getToolbarHeight() {
  int resourceId = SmartShow.getContext().getResources().getIdentifier("abc_action_bar_default_height_material", "dimen", "android");
  int height = 0;
  try {
    height = SmartShow.getContext().getResources().getDimensionPixelSize(resourceId);
  } catch (Resources.NotFoundException e) {
    height = Utils.dpToPx(56);
  }
  return height;
}

代码示例来源:origin: the-pig-of-jungle/smart-show

public static int getToolbarHeight() {
  int resourceId = SmartShow.getContext().getResources().getIdentifier("abc_action_bar_default_height_material", "dimen", "android");
  int height = 0;
  try {
    height = SmartShow.getContext().getResources().getDimensionPixelSize(resourceId);
  } catch (Resources.NotFoundException e) {
    height = Utils.dpToPx(56);
  }
  return height;
}

代码示例来源:origin: the-pig-of-jungle/smart-show

public static int getStatusBarHeight() {
  int resourceId = SmartShow.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
  int height = 0;
  try {
    height = SmartShow.getContext().getResources().getDimensionPixelSize(resourceId);
  } catch (Resources.NotFoundException e) {
    height = Utils.dpToPx(24);
  }
  return height;
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

private void setupInitialPosInfo() {
  mGravity = mToast.getGravity();
  mXOffset = mToast.getXOffset();
  mVerticalAxisOffsetWhenBottom = mYOffset = mToast.getYOffset();
  mVerticalAxisOffsetWhenTop = Utils.getToolbarHeight() + Utils.dpToPx(40);
}

代码示例来源:origin: the-pig-of-jungle/smart-show

private void setupInitialPosInfo() {
  mGravity = mToast.getGravity();
  mXOffset = mToast.getXOffset();
  mVerticalAxisOffsetWhenBottom = mYOffset = mToast.getYOffset();
  mVerticalAxisOffsetWhenTop = Utils.getToolbarHeight() + Utils.dpToPx(40);
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
protected void initBody(Dialog dialog, FrameLayout bodyViewWrapper) {
  super.initBody(dialog, bodyViewWrapper);
  TextView messageView = bodyViewWrapper.findViewById(R.id.smart_show_dialog_message_view);
  messageView.setText(mMessage);
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) messageView.getLayoutParams();
  lp.topMargin = Utils.isEmpty(mTitle) ? Utils.dpToPx(7) : 0;
  messageView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
    @Override
    public void onViewAttachedToWindow(View v) {
      TextView msgView = (TextView) v;
      if (msgView.getLineCount() > 1) {
        msgView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
      } else {
        msgView.setGravity(Gravity.CENTER);
      }
    }
    @Override
    public void onViewDetachedFromWindow(View v) {
    }
  });
  if (mMessageColor != 0) {
    messageView.setTextColor(mMessageColor);
  }
  if (mMessageTextSizeSp > 0) {
    messageView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mMessageTextSizeSp);
  }
  messageView.getPaint().setFakeBoldText(mMessageBold);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
protected void initBody(Dialog dialog, FrameLayout bodyViewWrapper) {
  super.initBody(dialog, bodyViewWrapper);
  TextView messageView = bodyViewWrapper.findViewById(R.id.smart_show_dialog_message_view);
  messageView.setText(mMessage);
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) messageView.getLayoutParams();
  lp.topMargin = Utils.isEmpty(mTitle) ? Utils.dpToPx(7) : 0;
  messageView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
    @Override
    public void onViewAttachedToWindow(View v) {
      TextView msgView = (TextView) v;
      if (msgView.getLineCount() > 1) {
        msgView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
      } else {
        msgView.setGravity(Gravity.CENTER);
      }
    }
    @Override
    public void onViewDetachedFromWindow(View v) {
    }
  });
  if (mMessageColor != 0) {
    messageView.setTextColor(mMessageColor);
  }
  if (mMessageTextSizeSp > 0) {
    messageView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mMessageTextSizeSp);
  }
  messageView.getPaint().setFakeBoldText(mMessageBold);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
protected void setupToast() {
  super.setupToast();
  mCurInfoType = TYPE_INFO_NORMAL;
  mCurIcon = R.drawable.type_info_normal;
  mWindowParams.windowAnimations = R.style.type_info_toast_anim;
  mWindowParams.height = Utils.dpToPx(85);
  if (ToastDelegate.get().hasToastSetting()
      && ToastDelegate.get().getToastSetting().isTypeInfoThemeColorSetup()) {
    GradientDrawable drawable = (GradientDrawable) mView.getBackground();
    drawable.setColor(ToastDelegate.get().getToastSetting().getTypeInfoThemeColor());
  }
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
protected void setupToast() {
  super.setupToast();
  mCurInfoType = TYPE_INFO_NORMAL;
  mCurIcon = R.drawable.type_info_normal;
  mWindowParams.windowAnimations = R.style.type_info_toast_anim;
  mWindowParams.height = Utils.dpToPx(85);
  if (ToastDelegate.get().hasToastSetting()
      && ToastDelegate.get().getToastSetting().isTypeInfoThemeColorSetup()) {
    GradientDrawable drawable = (GradientDrawable) mView.getBackground();
    drawable.setColor(ToastDelegate.get().getToastSetting().getTypeInfoThemeColor());
  }
}

相关文章