DrawingView-Android

授权协议 MIT License
开发语言 JavaScript
所属分类 应用工具、 图形和图像工具
软件类型 开源软件
地区 不详
投 递 者 充小云
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

DrawingView-Android



DrawingView is a simple view that lets you draw on screen using your fingers and lets you save the drawings as images.

Demo

Support Country Picker for Android

Drawing View is an independent project with ongoing development and support made possible thanks to donations made by these awesome backers. If you'd like to join them, please consider:

Getting started

Its really simple to integrate DrawingView in android. All you need to do make the following change to you build gradle.

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.mukeshsolanki:DrawingView-Android:<latest-version>'
}

How to use DrawingView

Its fairly simple and straight forward to use DrawingView in you application. Just add the following in your layout where you want to display the DrawingView.

<com.mukesh.DrawingView
  android:id="@+id/scratch_pad"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_above="@+id/buttons"
  />

and reference it in your activity/fragment and assign the DrawingView like wise.

DrawingView drawingView = (DrawingView) findViewById(R.id.scratch_pad);
drawingView.initializePen(); //To use the pen mode to draw on the screen
drawingView.initializeEraser(); //To use the eraser mode to clear the screen
drawingView.setBackgroundColor(@ColorInt int color); //To set the background color of the drawing view
drawingView.setEraserSize(float size); //To set the size of the eraser
drawingView.setPenSize(float size); //To set the size of the pen
drawingView.setPenColor(@ColorInt int color); //To set the color of the pen
drawingView.saveImage(String filePath, String filename, Bitmap.CompressFormat format, int quality); //To save the image after your done drawing
drawingView.loadImage(Bitmap bitmap); //Load image (your saved drawing)
drawingView.clear(); //clear image

Author

Maintained by Mukesh Solanki

Contribution

License

MIT License

Copyright (c) 2018 Mukesh Solanki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
  • 视图状态 视图状态的种类非常多,一共有十几种类型,不过多数情况下我们只会使用到其中的几种,因此这里我们也就只去分析最常用的几种视图状态。enabled 表示当前视图是否可用。可以调用setEnable()方法来改变视图的可用状态,传入true表示可用,传入false表示不可用。它们之间最大的区别在于,不可用的视图是无法响应onTouch事件的。focused 表示当前视图是否获得到焦点。通常情况下

  • 在工程src目录下新建一个类,继承于SurfaceView,实现Callback接口(SurfaceHolder.Callback,这个不知道干嘛用的,好像自定义控件需要用到它)和OntouchListener接口(区别OnClickListener),添加构造方法(还得是Context context, AttributeSet attrs两个参数的这种,虽然不知道为啥)和复写Callback接

  • 您应该覆盖视图的onDraw方法. screen_drawing_room.xml android:id="@+id/rlid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > android:layout_width="fill_pare

  • 首先这是一个跟随问题,原来在这里提出,Pan,Zoom and Scale a custom View for Canvas drawing in Android 应用缩放/缩放手势后,我发现画布绘图坐标仍然指向旧位置(在应用缩放之前),而不是绘制完全相同的触摸坐标.基本上,在缩放或拖动画布后,无法获得正确的画布坐标. 放大前, 缩小之后,触摸点正在绘制上一个位置.我想让它画在当前的触摸位置, 示

  • 我写了一个自定义视图类. 我在Main Layout xml上实现了自定义视图.并使用以下代码设置屏幕中心的参数 android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/cs_background" android:id="@+id/layout" >

  • 我从问题PorterduffXfermode: Clear a section of a bitmap中使用了有用的输入.在下面的示例中,触摸区域变为“透明”,可以观察up_image下面的down_image部分(这两个图像都是资源中的jpg drawable). 基本上有两种可能的实现: >禁用图形的硬件加速,这会使PorterDuff.Mode.CLEAR使视图透明(有关硬件加速效果的更多详

  • 我的簡單圖像編輯器有問題。 經過對比更改后,我嘗試設置新的編輯圖像,但異常出現。public ContrastBrightnessDialog(Context context, String title, final DrawingView drawView) { super(context); this.setContentView(R.layout.contrastbrightness_dia

  • 以下是从画布转换为位图并将其存储到图库或特定文件夹的步骤。 注意:请确保您已获得WRITE_EXTERNAL_STORAGE的权限 activity_main.xml android:id="@+id/linearLayout" android:orientation="horizontal" android:layout_margin="10dp" android:layout_width="w

  • 我正在开发一个我创建绘图镜像的项目。我的主要逻辑工作正常。导致问题的唯一原因是重做和撤消功能。 我搜索了很多。实施可能的方法,但无法取得成功。以下是我的绘图课程。 DrawingView.java private ArrayList paths = new ArrayList(); private ArrayList undonePaths = new ArrayList(); public Dr

  • 年初的时候刚把去年底的一个电子书包的项目完结了,这不刚过了几天又收到了boss新的需求:添加一个电子白板,要求老师端绘画的时候,学生端的屏幕也能看到老师端的操作。 难点:         1.画板的写法          2.如何推送数据到学生端,该推送什么格式的数据          3.学生端收到数据该如何绘制。 思路:          1.画板的写法ok,网上一大堆          2.

  • android自定义view状态保存 要保存view的状态,至少有两点需要满足: view要有id 要调用setSaveEnabled(true) <com.zxc.draganddraw.BoxDrawingView     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/drawin

 相关资料
  • 问题内容: 我正在尝试从一个发送客户类的对象,Activity然后在另一个对象中显示它Activity。 客户类的代码: 我想将其对象从一个对象发送Activity到另一个对象,然后在另一个对象上显示数据Activity。 我该如何实现? 问题答案: 一种选择是让你的自定义类实现该接口,然后可以使用该方法的变体在意图中额外传递对象实例。 伪代码:

  • 问题内容: 我很难找到最简单的方法来针对给定的JSON模式字符串验证JSON字符串(作为参考,这是在Java中运行在Android应用程序中)。 理想情况下,我只想传入JSON字符串和JSON模式字符串,并且它返回关于是否通过验证的布尔值。通过搜索,我发现了以下两个有前途的库可以完成此任务: http://jsontools.berlios.de/ https://github.com/fge/j

  • 问题内容: 我想每隔5秒重复调用一次方法,每当我希望停止该方法的重复调用时,我可能会停止或重新启动该方法的重复调用。 这是一些我真正想要实现的示例代码。在这方面请帮助我,我将非常感谢您。 问题答案: 使用以下命令设置重复任务: 如果您想取消任务,只需调用这里就是您的对象 并且您还可以检查答案下方的评论,他们已经提供了有关此内容的简短信息。

  • 问题内容: 我有一个活动,该活动的TabHost包含一组TabSpec,每个TabSpec都有一个listview,其中包含要由该选项卡显示的项目。创建每个TabSpec时,我设置一个图标以显示在选项卡标题中。 TabSpec是通过以下方法创建的,该方法循环创建适当数量的选项卡: 有几个实例,我希望能够更改程序执行过程中每个选项卡中显示的图标。目前,我正在删除所有选项卡,并再次调用上述代码以重新创

  • 问题内容: 如何通过android app向终端发送命令并获取输出?例如,发送“ ls /”并获取输出以在GUI中将其打印出来? 问题答案: 您必须使用反射来调用android.os.Exec.createSubprocess():

  • 问题内容: 我的应用程序显示了许多自定义对话框,例如“是/否”或“接受/取消决定”,并且在编写代码时,我意识到遵循相同的模式重复了太多代码。 我想建立一个通用类,但我不知道该怎么做,或更确切地说,我不知道该怎么做(接口,抽象类,继承,静态类等)。 这是我目前的课程: } 这就是我需要使用此类时要做的事情: 我敢肯定它是可改进的,但是您怎么能做到呢? 谢谢 问题答案: 首先创建一个Base 来保持的