当前位置:网站首页>Kotlin of Android cultivation manual - several ways to write a custom view
Kotlin of Android cultivation manual - several ways to write a custom view
2022-06-25 17:43:00 【sesame seeds】
- Click the jump =>《 Navigation post 》- Unity manual , Systematic practical learning
- Click the jump =>《 Navigation post 》- Android manual , Revisit mobile development
This article is about 2.6 Thousand characters , Novice reading needs 4 minute , Review needs 1 minute 【 Collect at any time, no longer get lost 】
About author
as everyone knows , Life is a long process , constantly overcome difficulties , Constantly reflect on the process of progress . In this process, there will be a lot of questions and thoughts about life , So I decided to put my thinking , Share all your experiences and stories , To find resonance !!!
Focus on Android/Unity And various game development skills , as well as Share various resources ( Website 、 Tools 、 material 、 Source code 、 Games etc. )
If you need anything, welcome me , Communication groups make learning No longer alone .

Premise
This is what Xiao Kong insisted on writing Android Novice series , Welcome to taste .
bosses (√)
Novice (√√√)
Practice process
Use Kotlin Not used to it , Take notes .
There are three ways
Mode one
recommend , Note that the first two construction parameters are this, instead of super
class WaveViewKotlin: View{
constructor(context: Context?) :this(context,null)
constructor(context: Context?, attrs: AttributeSet?) :this(context,attrs,0)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
init {
// Initialization method
}
override fun onDraw(canvas: Canvas) {
}
}
perhaps
class WaveViewKotlin: View{
constructor(context: Context?, attrs: AttributeSet?) :super(context,attrs)
init {
// Initialization method
}
override fun onDraw(canvas: Canvas) {
}
}
Mode two
The other one parameter and three parameters are infeasible
class WaveViewKotlin(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
init {
// Initialization method
}
override fun onDraw(canvas: Canvas) {
}
}
Mode three
The premise is that the project's build In the configuration kotlin Plug in for .
class WaveViewKotlin @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr){
init {
// Initialization method
}
override fun onDraw(canvas: Canvas) {
}
}
other
author : Xiaokong and Xiaozhi Xiaokong
Reprint note - Be sure to indicate the source :https://zhima.blog.csdn.net/
This Taoist friend, please Step back ️, I watch you Extraordinary bearing , There is a king's domineering spirit in his speech , There will be a great achievement in the future !!! There is give the thumbs-up Collection Today I tell you , Have you ordered it , Your success in the future ️, I don't take a penny , If it doesn't work ️, Or come back to me .
reminder : Click the card below to get more unexpected resources .
边栏推荐
猜你喜欢
随机推荐
杰理之定时器捕获(timer_cap.c)使用注意事项【篇】
Essential characteristics of convolution operation +textcnn text classification
How does LSF see whether the job reserved slot is reasonable?
大学生暑假换机热,ROG 明星产品幻 16 翻转版 / 幻 13 / 幻 X 预约
CVPR小目标检测:上下文和注意力机制提升小目标检测(附论文下载)
Distinguishing seven kinds of facial expressions by deep separable convolution neural network
Jerry's system clock setting is reset or invalid [chapter]
十大证券公司哪个佣金最低 办理开户安全吗
mvdr波束 matlab,mvdr波束形成matlab[通俗易懂]
用户调度问题
杰理之adc_get_voltage 函数获取电压值不准【篇】
【Matlab】曲线拟合
[matlab] numerical calculus and equation solving
杰理之系统时钟设置出现复位或无效问题【篇】
HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
Interrupt operation: abortcontroller learning notes
CONDA modifying a mirror source
【UVM实战 ===> Episode_2 】~ VIP、VIP的开发、VIP的发布
Intelligent dialog 01 redis installation
Precautions for using Jerry's timer [chapter]









