Base Data Binding Relative Layout
RelativeLayout that uses DataBinding and sets a LifecycleOwner.
Binds lifecycle on attach and releases on detach.
DataBinding을 사용하는 RelativeLayout입니다.
attach 시 LifecycleOwner를 연결하고 detach 시 해제합니다.
Why this class exists / 이 클래스가 필요한 이유:
Provides lifecycle-aware DataBinding for custom RelativeLayout components.
Ideal for legacy layouts with LiveData-bound relative positioned views.
Automatically sets lifecycleOwner for LiveData observation in XML.
커스텀 RelativeLayout 컴포넌트에 생명주기 인식 DataBinding을 제공합니다.
LiveData 바인딩된 상대 위치 뷰가 있는 레거시 레이아웃에 적합합니다.
XML에서 LiveData 관찰을 위해 자동으로 lifecycleOwner를 설정합니다.
Usage / 사용법:
Extend this class and pass the layout resource ID.
Override onInitBind() to bind ViewModel and perform initial setup.
Override onEventVmCollect() to collect ViewModel events with repeatOnLifecycle.
Use XML data binding expressions to bind views to ViewModel properties.
이 클래스를 상속받고 레이아웃 리소스 ID를 전달하세요.
ViewModel을 바인딩하고 초기 설정을 수행하려면 onInitBind()를 오버라이드하세요.
repeatOnLifecycle로 ViewModel 이벤트를 수집하려면 onEventVmCollect()를 오버라이드하세요.
XML 데이터 바인딩 표현식을 사용하여 뷰를 ViewModel 프로퍼티에 바인딩하세요.
Usage example:
// 1. Define custom layout class
class PlayerControlView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
) : BaseDataBindingRelativeLayout<LayoutPlayerControlBinding>(
context, attrs,
layoutId = R.layout.layout_player_control,
) {
private val viewModel: PlayerControlViewModel by lazy { /* get ViewModel */}
override fun onInitBind(binding: LayoutPlayerControlBinding) {
binding.viewModel = viewModel
// LiveData properties like isPlaying, currentPosition will auto-update
}
}
// 2. XML layout (layout_player_control.xml)
// <layout>
// <data>
// <variable name="viewModel" type="PlayerControlViewModel" />
// </data>
// <RelativeLayout ...>
// <ImageButton android:src="@{viewModel.isPlaying ? @drawable/pause : @drawable/play}"
// android:layout_centerInParent="true" />
// <SeekBar android:progress="@{viewModel.currentPosition}"
// android:layout_alignParentBottom="true" />
// </RelativeLayout>
// </layout>Parameters
The type of ViewDataBinding to be used.
사용할 ViewDataBinding 타입.
See also
For the parent class with binding lifecycle management.
바인딩 생명주기 관리가 있는 부모 클래스는 ParentsBindingRelativeLayout을 참조하세요.
For ViewBinding variant without LiveData auto-binding.
LiveData 자동 바인딩이 없는 ViewBinding 버전은 BaseViewBindingRelativeLayout을 참조하세요.
Constructors
Properties
Functions
Binds a lifecycle observer to the current LifecycleOwner.
Replaces the observer if the owner changes, prevents duplicate registration.
현재 LifecycleOwner에 라이프사이클 옵저버를 바인딩합니다.
Owner가 변경되면 옵저버를 교체하고, 중복 등록을 방지합니다.
Executes a block when the view has been laid out and measured.
Useful for getting actual view dimensions.
View가 레이아웃되고 측정된 후 블록을 실행합니다.
실제 View 크기를 얻는 데 유용합니다.
Toggles visibility with fade animation.
페이드 애니메이션과 함께 가시성을 토글합니다.
Finds the host LifecycleOwner for this View.
Prioritizes Fragment's viewLifecycleOwner, falls back to Activity.
이 View의 호스트 LifecycleOwner를 찾습니다.
Fragment의 viewLifecycleOwner를 우선시하고, 없으면 Activity를 사용합니다.
Iterates over all child views of this ViewGroup.
이 ViewGroup의 모든 자식 View를 반복합니다.
Gets the view's location on screen as a Pair.
View의 화면상 위치를 Pair로 가져옵니다.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Called to start collecting ViewModel events.
Typically invoked once per lifecycle (e.g., onCreate or onViewCreated).
ViewModel 이벤트 수집을 시작할 때 호출됩니다.
보통 생명주기 당 1회(onCreate 또는 onViewCreated) 호출됩니다.
Called when the binding is initialized in onCreate().
Implement setup logic that requires binding here.
onCreate에서 바인딩이 초기화된 후 호출됩니다.
바인딩이 필요한 초기화 로직을 여기서 수행하세요.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Lifecycle callback placeholder for subclasses.
하위 클래스에서 필요한 경우 오버라이드하는 생명주기 콜백입니다.
Sets the view's visibility to GONE.
View의 가시성을 GONE으로 설정합니다.
Sets the height of the view.
View의 높이를 설정합니다.
Sets the view height to match parent.
View의 높이를 부모에 맞춥니다.
Sets the view height to wrap content.
View의 높이를 내용에 맞춥니다.
Sets the view's visibility to INVISIBLE.
View의 가시성을 INVISIBLE로 설정합니다.
Sets uniform margin for all sides.
모든 면에 대해 동일한 여백을 설정합니다.
Sets all margin values at once.
모든 여백 값을 한 번에 설정합니다.
Sets a debounced click listener on this view to prevent rapid consecutive clicks.
Uses View's tag system to store timing information, preventing memory leaks.
연속적인 빠른 클릭을 방지하기 위해 디바운스된 클릭 리스너를 설정합니다.
View의 tag 시스템을 사용하여 타이밍 정보를 저장하여 메모리 누수를 방지합니다.
Sets uniform padding for all sides.
모든 면에 대해 동일한 패딩을 설정합니다.
Sets the view's visibility to VISIBLE.
View의 가시성을 VISIBLE로 설정합니다.
Sets the width of the view.
View의 너비를 설정합니다.
Sets the view width to match parent.
View의 너비를 부모에 맞춥니다.
Sets the view width to wrap content.
View의 너비를 내용에 맞춥니다.
Creates an indefinite duration Snackbar without showing it.
The Snackbar will remain visible until dismissed.
표시하지 않고 무제한 시간 Snackbar를 생성합니다.
Snackbar는 닫힐 때까지 계속 표시됩니다.
Creates a long duration Snackbar without showing it.
Allows further customization before displaying.
표시하지 않고 긴 시간 Snackbar를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates a short duration Snackbar without showing it.
Allows further customization before displaying.
표시하지 않고 짧은 시간 Snackbar를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates and shows an indefinite duration Snackbar from a View.
View에서 무제한 시간 Snackbar를 생성하고 표시합니다.
Creates and shows an indefinite duration Snackbar with a custom view.
커스텀 뷰로 무제한 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a long duration Snackbar from a View.
View에서 긴 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a long duration Snackbar with a custom view.
커스텀 뷰로 긴 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a short duration Snackbar from a View.
View에서 짧은 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a short duration Snackbar with a custom view.
커스텀 뷰로 짧은 시간 Snackbar를 생성하고 표시합니다.
Unbinds the lifecycle observer from this View.
Should be called when detaching the view or changing parent.
이 View에서 라이프사이클 옵저버를 언바인딩합니다.
View를 분리하거나 부모를 변경할 때 호출해야 합니다.