Making a custom view class and drawing with the Canvas class.
Use lines, circles, rectangles, and polygons to draw a pretty Spring image
Read about supporting different pixel densities here
If you need help, you can follow my github.com examples
https://github.com/dltra/02AnimatedGame/commits/master
In particular look at the first 3 commits
Don't look at the others commits until you are ready for the next part.
Bonus: Put your custom drawing into a Fragment.
Download this doc as a Word document
Use the Table of Contents links to jump to where you need
Final code solution files are embedded at end of document
Double Bonus: Cycle through 2 or more drawings using Fragments
Fun method:
canvas.drawTextOnPath(TEXT, path, x, y, paint)
Slides
Screenshot or video your tutorial drawing
Build the .apk file
Rename the .apk file
PeriodLabNumberLastFirstCustomName.apk
P8L08aTraDanBasicDrawing.apk
Submit assignment
Video or screenshot of drawing
.apk file
.java files
.xml files
Draw, animate, and/or add sound - Pick a theme and make something fun.
Bonus:
Create a Sprite class using RectF and handle instance collisions or touch detection
Submit as Lab08b
P8L08bTraDanBestDrawing.apk
Submit video as appropriate
Mirror
canvas.save();
canvas.scale(-1.0f, 1.0f, x, y); //reflects vertically about the point (x,y)
canvas.drawBitmap(bitmap, 0, 0, null); //draws bitmap at (0,0)
canvas.restore();
Rotate
canvas.save();
canvas.rotate(num, x, y); //rotate num degrees about the point (x,y)
canvas.drawRect(customRect, paint); //draw custom rectangle using pre-defined paint
canvas.restore();
p.setShader(new LinearGradient(left, bottom, right, top, startColor, endColor, Shader.TileMode.MIRROR));
https://pspdfkit.com/blog/2017/50-shaders-of-android-drawing-on-canvas/
Gradle Scripts>build.gradle(Module:app)
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
In your desired .xml file
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:src="@drawable/youranimategif" />