自定義控制項

2021-08-14 09:54:03 字數 3108 閱讀 2615

太極

package bwie.com.zidongyi.view;

import android.content.context;

import android.graphics.canvas;

import android.graphics.color;

import android.graphics.paint;

import android.graphics.path;

import android.graphics.rectf;

import android.support.annotation.nullable;

import android.util.attributeset;

import android.view.view;

/*** created by lenovo on 2017/12/27.

*/public class

taiji

extends view

public taiji(context context, @nullable attributeset attrs)

public taiji(context context, @nullable attributeset attrs, int defstyleattr)

@override

protected void ondraw(canvas canvas)

}

五角星

package bwie.com.zidongyi.view;

import android.content.context;

import android.graphics.canvas;

import android.graphics.color;

import android.graphics.paint;

import android.graphics.path;

import android.support.annotation.nullable;

import android.util.attributeset;

import android.view.view;

/*** created by lenovo on 2017/12/27.

*/public class

wujiaoxing

extends view

public wujiaoxing(context context, @nullable attributeset attrs)

public wujiaoxing(context context, @nullable attributeset attrs, int defstyleattr)

@override

protected void ondraw(canvas canvas)

}

五星紅旗

package bwie.com.zidongyi.view;

import android.content.context;

import android.graphics.canvas;

import android.graphics.color;

import android.graphics.paint;

import android.graphics.path;

import android.support.annotation.nullable;

import android.util.attributeset;

import android.view.view;

/*** created by lenovo on 2017/12/27.

*/public class

wuxinghongqi

extends view

public wuxinghongqi(context context, @nullable attributeset attrs)

public wuxinghongqi(context context, @nullable attributeset attrs, int defstyleattr)

@override

protected void ondraw(canvas canvas)

}

觸控移動

package bwie.com.zidongyi.view;

import android.content.context;

import android.graphics.canvas;

import android.graphics.color;

import android.graphics.paint;

import android.support.annotation.nullable;

import android.util.attributeset;

import android.view.motionevent;

import android.view.view;

/*** created by lenovo on 2017/12/27.

*/public class

yidong

extends view

public yidong(context context, @nullable attributeset attrs)

public yidong(context context, @nullable attributeset attrs, int defstyleattr)

@override

protected void ondraw(canvas canvas)

@override

public boolean ontouchevent(motionevent event)

//需要重新繪製一下圖形

//invalidate();//但是只能在主線程進行圖形的繪製

postinvalidate();//主線程和子執行緒都可以....呼叫這兩個方法的時候,會自動呼叫ondraw方法

//觸控事件自己處理

return true;

}}

自定義控制項 自定義鐘錶

private context mcontext 畫筆 private paint mpaint 控制項的寬 private int mwidth x方向的圓心座標 private int center 鐘錶的半徑 private int mradio 圓環的寬 private int stroke...

自定義控制項

首先是以下這幾項,attribute defaultproperty指定元件的預設屬性,toolboxdata指定當從ide工具中的 工具箱中拖動自定義控制項時為它生成的預設標記 defaultproperty text toolboxdata mycontrol runat server 上面這些...

自定義控制項

新聞管理 using system using system.collections.generic using system.linq using system.web using system.web.ui using system.web.ui.webcontrols namespace ne...