Simple notepad app code android studio
- #Simple notepad app code android studio how to
- #Simple notepad app code android studio update
- #Simple notepad app code android studio code
#Simple notepad app code android studio code
Below is the code for the activity_main.xml file. Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Step 3: Working with the activity_main.xml file Implementation ‘petrov.kristiyan:colorpicker-library:1.1.10’ This library is used to add a color palette to our app so that the user can select any color of his choice Step 2: Adding the dependency in gradle.build Note that select Java as the programming language.
#Simple notepad app code android studio how to
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. So leave the AndroidManifest.xml as default. This app doesn’t require any special permissions. (x1,y1) is the control point on a quadratic curve and (x2,y2) This method smoothens the curves using a quadratic line. Path.quadTo (float x1,float y1, float x2, float y2) The last time the was canvas.save() called. This method reverts the Canvas’s adjustments back to This method saves the current state of the Canvas We call invalidate() which further internally calls the onDraw() method.
#Simple notepad app code android studio update
Whenever we want to update the screen, in our case the Canvas, This method calls the overridden onDraw() method. Results are undefined if the alpha value is outside of the range It is a helper method that only assigns the color’sĪlpha value, leaving its r,g,b values unchanged. This method sets the paint to join to either ROUND, BEVEL, MITER Line as per the argument For example, ROUND, SQUARE, BUTT. This method changes the geometry of the endpoint of the Has little effect on the shape’s interior. Higher precision than the device’s accuracy.ĪntiAliasing smooths out the edges of what is drawn but So, we provide the Save option, which will allow the user to save the current canvas in form of a PNG or JPEG.īefore jumping to the code here are a few of the methods which we will be using in building our app:ĭithering affects the down-sampling of colors that are of Now, at the end when the user is done with the drawing, he might want to save that painting for any further use.This ArrayList will help us in undoing the Stroke which the user has drawn mistakenly on the Canvas. In order to keep a record of each and every stroke the user has drawn on the Canvas, we will create an ArrayList of type Stroke.Each object of this class will represent a distinct brush that draws a unique stroke on the canvas. a class named Stroke with attributes like the color of the stroke, the width of the stroke, visibility of stroke, etc. Now since we need different brushes for different colors and different widths of the stroke, we will create a blueprint i.e. Then we will require a brush that acts as a tool to help us draw on the canvas.In order to achieve this, we create a DrawView class which extends the View class from the standard Android SDK. And for that, we need to create a custom view where the user could simply drag the finger to draw the strokes. So, in our app, we will firstly create a canvas where the user can draw his drawings.
![simple notepad app code android studio simple notepad app code android studio](https://i.pinimg.com/originals/11/b0/10/11b0101c1c0a2a4c680ee67096f1ad14.jpg)