일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- notification
- CollapsingToolbarLayout
- Coroutine
- activity
- 알고리즘
- onLayout
- Navigation
- hilt
- sqlite
- Algorithm
- 코틀린
- recyclerview
- HTTP
- onMeasure
- Android
- CustomView
- View
- AppBarLayout
- ViewModel
- lifecycle
- Behavior
- 백준
- BOJ
- room
- LiveData
- kotlin
- 안드로이드
- 알림
- DataBinding
- CoordinatorLayout
- Today
- Total
목록CustomView (5)
개발일지
View가 그려지는 순서는 measure -> layout -> draw 과정을 거친다. 또한 전위순회 방식(부모를 그리고 자식을 형제순으로) 으로 그린다. Measure measure(widthMeasureSpec: Int, heightMeasureSpec: Int) View의 크기를 측정하는 과정이다. final 함수이지만 내부적으로 onMeasure를 호출하고 onMeasure를 재정의하여 사용할 수 있다. 아직 ChildView는 measure된 상태가 아니기 때문에 width, measuredWidth 는 0이 반환될 수 있다. setMeasureDimension(measuredWidth: Int, measuredHeight: Int) View의 크기를 측정한다. onMeasure에서 필수적으로..

View와 ViewGroup을 상속받아서 직접 View를 만들 수 있지만 기존의 정의된 View나 ViewGroup을 상속 받아서 기능을 확장할 수 있다. View 만들기 class LoginButtonView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : MaterialCardView(context, attrs, defStyleAttr), DataBinding { override val binding: ViewLoginButtonBinding by lazy { DataBinding.get(this, R.layout.view_login_b..

CustomeViewGroup Android에서 기본으로 제공하는 ViewGroup(Layout) 대신 ViewGroup을 상속받아 UI를 구축할 수 있다. OverlapLayout 전체코드 class OverlapLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : ViewGroup(context, attrs, defStyleAttr, defStyleRes) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { var width = 0 var height..

CustomView Android에서 기본으로 제공하는 View로 UI를 구축할 수 없을 때 사용자가 직접 View를 상속받아서 CustomView를 만들 수 있다. ProgressView 전체코드 class ProgressView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : View(context, attrs, defStyleAttr, defStyleRes) { private val progressBarBackgroundPaint = Paint().apply { isAntiAlias = true style = Paint.Style.ST..

AttributeSet Android는 XML에서 View를 생성할 때 값을 설정할 수 있는 AttributeSet 인터페이스를 제공합니다. AttributeSet을 통해 View를 생성하면서 기본값을 쉽게 설정할 수 있습니다. View 만들기 View를 상속받고 기본 생성자를 설정한다. class ProgressView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : View(context, attrs, defStyleAttr, defStyleRes) { } AttributeSet 만들기 attr.xml에 선언하여 만들 수 있다. refe..