实现了热量值计算

This commit is contained in:
zxj
2025-08-04 18:02:45 +08:00
parent 5ae72cdf04
commit c6badf2ca7
14 changed files with 431 additions and 32 deletions
@@ -1,15 +1,18 @@
package com.sw.dualscreen.view;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import com.sw.dualscreen.R;
import com.sw.plate.utils.AppUtil;
public class CustomImageView extends androidx.appcompat.widget.AppCompatImageView {
@@ -23,29 +26,37 @@ public class CustomImageView extends androidx.appcompat.widget.AppCompatImageVie
private static final int MAX_HEIGHT = 280;
private boolean isDrawText = false;
private Drawable bigRedDrawable;
private Drawable bigGreenDrawable;
private Drawable redDrawable;
private Drawable greenDrawable;
public CustomImageView(Context context) {
super(context);
init();
init(context);
}
public CustomImageView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
init(context);
}
public CustomImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
init(context);
}
private void init() {
@SuppressLint("UseCompatLoadingForDrawables")
private void init(Context context) {
textToDraw = "超标";
mPaint = new Paint();//Paint.ANTI_ALIAS_FLAG
mPaint.setColor(Color.WHITE); // Set your desired color
mPaint.setTextSize(mTextSize); // Set your desired text size
mPaint.setAntiAlias(true);
bigRedDrawable = context.getDrawable(R.drawable.img_big_red_column);
bigGreenDrawable = context.getDrawable(R.drawable.img_big_green_column);
redDrawable = context.getDrawable(R.drawable.img_red_column);
greenDrawable = context.getDrawable(R.drawable.img_green_column);
// Typeface typeface = getResources().getFont(R.font.dakai);
// Typeface typeface = Typeface.create(Typeface.createFromAsset(getContext().getAssets(), "fonts/dakai.TTF"),
// Typeface.BOLD); // 创建Typeface
@@ -69,6 +80,20 @@ public class CustomImageView extends androidx.appcompat.widget.AppCompatImageVie
}
}
/**
* 设置图片
*
* @param isBig 大图
* @param isMore 是否超过
*/
public void setImageDrawable(boolean isBig, boolean isMore) {
if (isBig) {
setImageDrawable(isMore ? bigRedDrawable : bigGreenDrawable);
} else {
setImageDrawable(isMore ? redDrawable : greenDrawable);
}
}
public void setCustomHeightPercent(float percent, boolean isAnimation) {
setCustomHeight((int) (percent * MAX_HEIGHT), isAnimation);
}