I have updated my PaintView code because according to my android studio error log, it says that I need to extends to android.app.activity but now I have a null reference error in my Bitmap getwidth(). I am new to android app but from my understanding, it is not returning the object because it can't find bitmap? Here is my PaintView class:
public class PaintView extends android.app.Activity{
LayoutParams params;
Path path = new Path();
Paint br = new Paint();
Bitmap background;
Bitmap background2;
public PaintView(Context context) {
super();
int maxHeight = 2000;
int maxWidth = 1000;
float scale = Math.min(((float) maxHeight / background.getWidth()), ((float) maxWidth / background.getHeight()));
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
background = Bitmap.createBitmap(background, 0, 0, background.getWidth(), background.getHeight(), matrix, true);
background2 = Bitmap.createBitmap(background2, 0, 0, background2.getWidth(), background2.getHeight(), matrix, true);
br.setColor(Color.GREEN);
br.setStyle(Paint.Style.STROKE);
br.setStrokeJoin(Paint.Join.ROUND);
br.setStrokeWidth(10f);
params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
private float getHeight() {
int height = 5;
return height;
}
private float getWidth() {
int width = 5;
return width;
}
//@Override
public void onClick(View view) {
Log.i("Hello", "Hello you!");
}
}