Android project notepad (10), android Project

Source: Internet
Author: User

Android project notepad (10), android Project

In the previous section, all the functions of the canvas are implemented, including setting the paint brush size, setting the paint brush color, and eraser. You can also add the handwriting size and color setting functions, this section allows you to adjust handwriting size and color.

First look at the figure:

In fact, the functions of handwriting and drawing board are similar. Simply reuse the previous code. The principle is as follows:

1. Set the paint brush size:

1) initialize the paint brush.

2) set the paint brush size to the selected size.

3) Use a variable to remember the size of the current paint brush. It is used to keep the size of the previously set paint brush after other operations.

2. Set the paint brush color:

1) initialize the paint brush.

2) set the paint brush color to the selected color.

3) Use a variable to remember the color of the current paint brush. It is used to maintain the color of the previously set paint brush after other operations.

The main code (added in TouchView) is as follows:

private Paint mPaint;private int currentColor = Color.RED;private int currentSize = 5;
// Set the Paint brush style public void setPaintStyle () {mPaint = new Paint (); mPaint. setAntiAlias (true); mPaint. setDither (true); mPaint. setStyle (Paint. style. STROKE); mPaint. setStrokeJoin (Paint. join. ROUND); mPaint. setStrokeCap (Paint. cap. ROUND); mPaint. setStrokeWidth (currentSize); mPaint. setColor (currentColor );}

 

Set the paint brush size:

// Set the size of the paint brush public void selectHandWritetSize (int which) {int size = Integer. parseInt (this. getResources (). getStringArray (R. array. paintsize) [which]); currentSize = size; setPaintStyle ();}

 

Set the paint color:

// Set the paint brush color public void selectHandWriteColor (int which) {currentColor = paintColor [which]; setPaintStyle ();}


After these methods are added to the custom View, these methods are called in the Activity, as shown in the preceding section (Add the following code in HandWriteActivity. java ):

// Paint brush size case 0: showPaintSizeDialog (view); break; // color case 1: showPaintColorDialog (view); break;

Click these two buttons to bring up a dialog box to select the size and color of the paint brush.

ShowPaintSizeDialog (view). The select brush size dialog box is displayed, as shown below:

// Public void showPaintSizeDialog (View parent) {AlertDialog. builder alertDialogBuilder = new AlertDialog. builder (this, R. style. custom_dialog); alertDialogBuilder. setTitle ("select the paint brush size:"); alertDialogBuilder. setSingleChoiceItems (R. array. paintsize, select_handwrite_size_index, new DialogInterface. onClickListener () {@ Overridepublic void onClick (DialogInterface dialog, int which) {select_handwrite_size_index = which; touchView. selectHandWritetSize (which); dialog. dismiss () ;}}); alertDialogBuilder. setNegativeButton ("cancel", new DialogInterface. onClickListener () {@ Overridepublic void onClick (DialogInterface dialog, int which) {dialog. dismiss () ;}}); alertDialogBuilder. create (). show ();}


ShowPaintColorDialog (view): The color selection dialog box is displayed, as follows:

// Public void showPaintColorDialog (View parent) {AlertDialog. builder alertDialogBuilder = new AlertDialog. builder (this, R. style. custom_dialog); alertDialogBuilder. setTitle ("select paint color:"); alertDialogBuilder. setSingleChoiceItems (R. array. paintcolor, select_handwrite_color_index, new DialogInterface. onClickListener () {@ Overridepublic void onClick (DialogInterface dialog, int which) {select_handwrite_color_index = which; touchView. selectHandWriteColor (which); dialog. dismiss () ;}}); alertDialogBuilder. setNegativeButton ("cancel", new DialogInterface. onClickListener () {@ Overridepublic void onClick (DialogInterface dialog, int which) {dialog. dismiss () ;}}); alertDialogBuilder. create (). show ();}

 

The arrays. xml mentioned in the previous section is also used.

Arrays. xml

<?xml version="1.0" encoding="utf-8"?><resources>    <string-array name="paintstyle">        <item>@string/track_line</item>        <item>@string/Eraser</item>    </string-array>    <string-array name="paintsize">        <item>5</item>        <item>10</item>        <item>15</item>        <item>20</item>        <item>25</item>        <item>30</item>    </string-array>     <string-array name="paintcolor">        <item>RED</item>        <item>BLUE</item>        <item>BLACK</item>        <item>GREEN</item>        <item>YELLOW</item>        <item>CYAN</item>        <item>LTGRAY</item>    </string-array>    </resources>

At this point, the hand-writing function has been basically completed, and the next step is to save the hand-writing words into a file, and return the path to save the file to the database, which will continue to be improved in the future.

 






 

 

 

 

 


Android notepad and Android notepad

There are a lot of Android mobile phone notepad software. Which of the following Landlords prefer to use it on their own. I know several easy-to-use notepad software and recommend it to the landlord.

Some software can be downloaded in [Android park]. You only need to enter the notepad to find it.

[Handwritten notepad]
HandCalendar is a notebook, notebook, and notebook that supports handwriting. It also supports saving recorded content to the calendar. The handwriting function of the software is relatively powerful. It supports 10 colors and 3 pen styles, and supports a maximum of three erasers to cancel the function.

[AK Notepad]
AK notepad is a powerful text document editing software. In addition to editing, reading, and writing documents and viewing TXT documents, the software also allows you to share event reminders with others through text messages, emails, and mobile phone alarms.

[With handwriting]
Hand-writing is definitely the most convenient convenience software, and the original smart scaling. Supports both handwriting (Original Handwriting) and keyboard input. Features: 1. You can remember big things on a small screen and use the original handwriting keyboard mixed-mode.
2. task management, notes, calendar, alarm clock, MMS, and schedule 3. Free graffiti, illustrations, photo notes, and voice notes on photos 4. widgets read the current notebook directly.

How can I export the content of my notepad from my Android phone?

Install 920 editor .apk on your mobile phone
Copy the content of notepad, open the 920 text editor, and paste it,
Save it to the SD card.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.