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"
/>
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;
}
最后
这里我特地整理了一份《Android开发核心知识点笔记》,里面就包含了自定义View相关的内容
如果你有需要的话,可以私信我【进阶】发给你
除了这份笔记,还给大家分享 Android学习PDF+架构视频+面试文档+源码笔记,高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料这几块的内容。非常适合近期有面试和想在技术道路上继续精进的朋友。
如果你有需要的话,可以点击我的GitHub免费获取!
分享上面这些资源,希望可以帮助到大家提升进阶,如果你觉得还算有用的话,不妨把它们推荐给你的朋友~
喜欢本文的话,给我点个小赞、评论区留言或者转发支持一下呗~