Android Custom View 만들기
사용 버전: Android Studio 4.0
사용 언어: Kotlin 1.3.72
안드로이드 Custom View 만들기를 해보겠습니다.
Custom View는 사용자가 만든 View를 말합니다.
Custom View로 사용할 Class를 하나 만듭니다.
저는 InAppKeyboard로 만들겠습니다.

아래처럼 기본 Class를 수정합니다.
ConstraintLayout을 적은 이유는 ConstraintLayout으로 사용하려고 적었습니다.
다른 View를 적으셔도 됩니다.

layout에 해당 class에서 사용할 layout을 만듭니다.
저는 in_app_keyboard.xml로 만들었습니다.

디자인은 다음과 같습니다.

다시 InAppKeyboard로 돌아옵니다.
init을 적습니다. inflate에 위에서 만든 layout을 적습니다.

Custom View를 사용하고자 하는 layout에 일반 View처럼 추가합니다.

추가되었습니다.

끝.
카테고리: Android
댓글
댓글 쓰기
궁금한 점은 댓글 달아주세요.
Comment if you have any questions.