当前位置:网站首页>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 .
边栏推荐
- Treasure and niche Chinese painting 3D texture material website sharing
- 汇编语言(6)使用JCC指令构造分支与循环
- Jerry's ADC_ get_ Incorrect voltage value obtained by voltage function [chapter]
- IDEA全局搜索汉字[通俗易懂]
- container of()函数简介
- Precautions for use of Jerry's SPI slave [chapter]
- TLV decoding
- Assembly language (6) uses JCC instructions to construct branches and loops
- 使用DiskGenius拓展系統盤C盤的容量
- WARNING: Unsupported upgrade request.
猜你喜欢
观察者模式之通用消息发布与订阅
汇编语言(5)寄存器(内存访问)
HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
Introduction to the container of() function
[machine learning] case study of college entrance examination prediction based on multiple time series
【编译原理】概述
WARNING: Unsupported upgrade request.
win10安装cuda的操作步骤(不断完美中)
BILSTM和CRF的那些事
【编译原理】词法分析
随机推荐
什么是算子?
数学建模——整数规划
Time series analysis of data mining [easy to understand]
TLV decoding
匯編語言(5)寄存器(內存訪問)
golang sort slice int
视频制作素材网站整理
启牛的涨乐财付通如何?安全靠谱吗
用户调度问题
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
【编译原理】词法分析
用连续自然数之和来表达整数
杰理之获取复位源和唤醒的 IO 口的方法【篇】
图标丢失,URL附带JESSSIONID的什么来的?
UART波特率对时钟精度的要求有多高?
揭秘GES超大规模图计算引擎HyG:图切分
相同wifi下,笔记本连接台式机上的虚拟机
Is Guotai Junan Securities reliable? Is it legal? Is it safe to open a stock account?
How to solve the problem of network disconnection after enabling hotspot sharing in win10?
Mathematical modeling - nonlinear programming