1效果图

实现步骤
1、添加画板控件module
画板控件module下载:https://download.youkuaiyun.com/download/meixi_android/10774781
2、xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/content_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginTop="8dp"
android:background="@color/blistlic"></LinearLayout>
<Button
android:id="@+id/btn_reset"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:text="重置"
android:textSize="16dp"
android:textColor="#fff"
android:background="@drawable/selebuttonbg"/>
<Button
android:id="@+id/btn_bitmap"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:text="确认"
android:textSize="16dp"
android:background="@drawable/selebuttonbg"
android:textColor="#fff" />
<com.unco.library.PainterView
android:id="@+id/painter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/defaulcolor"
/>
</LinearLayout>
3、activity代码详情
/**
* 作者:created by meixi
* 邮箱:13164716840@163.com
* 日期:2018/11/9 13
*/
public class QianmingActivity extends MainBaseFragmentActiciry {
@BindView(R.id.backliqianming)
LinearLayout backliqianming;
@BindView(R.id.btn_reset)
Button btn_reset;
@BindView(R.id.btn_bitmap)
Button btn_bitmap;
@BindView(R.id.painter)
PainterView painter;
private String ss;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.qianmingla);
ButterKnife.bind(this);
ss = getIntent().getStringExtra("type");
painter.clear();
}
@OnClick({R.id.backliqianming,R.id.btn_reset,R.id.btn_bitmap})
public void onClick(View view) {
switch (view.getId()) {
case R.id.backliqianming:
onBackPressed();
break;
case R.id.btn_reset:
painter.clear();
break;
case R.id.btn_bitmap:
Bitmap bitmap = painter.creatBitmap();
if (ss.equals("ww")){
BObServernotice.getInstance().notifyObserver(1,bitmap);
}else if (ss.equals("jj")){
BObServernotice.getInstance().notifyObserver(2,bitmap);
}
onBackPressed();
break;
}
}
}
本文详细介绍了一款手绘签名板的实现过程,包括画板控件的添加、XML布局配置及Activity代码详解。通过本教程,读者可以学会如何创建并使用自定义的签名板控件,以及如何将签名转换为位图。
352

被折叠的 条评论
为什么被折叠?



