mirror of
https://github.com/BetterAndroid/Hikage.git
synced 2025-09-03 17:25:24 +08:00
feat: add LP generic function in ViewGroup
This commit is contained in:
@@ -219,7 +219,7 @@ Or, use in a custom `View`.
|
||||
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
||||
|
||||
init {
|
||||
addView {
|
||||
addView<FrameLayout.LayoutParams> {
|
||||
TextView {
|
||||
text = "Hello, World!"
|
||||
textSize = 16f
|
||||
|
@@ -217,7 +217,7 @@ root.addView {
|
||||
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
||||
|
||||
init {
|
||||
addView {
|
||||
addView<FrameLayout.LayoutParams> {
|
||||
TextView {
|
||||
text = "Hello, World!"
|
||||
textSize = 16f
|
||||
|
@@ -30,6 +30,18 @@ import com.highcapable.hikage.core.base.HikageFactoryBuilder
|
||||
import com.highcapable.hikage.core.base.HikagePerformer
|
||||
import com.highcapable.hikage.core.base.Hikageable
|
||||
|
||||
/**
|
||||
* @see ViewGroup.addView
|
||||
* @see Hikageable
|
||||
* @return [Hikage]
|
||||
*/
|
||||
@JvmName("addViewTyped")
|
||||
inline fun <reified LP : ViewGroup.LayoutParams> ViewGroup.addView(
|
||||
index: Int = -1,
|
||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||
performer: HikagePerformer<LP>
|
||||
) = Hikageable<LP>(context = context, factory = factory, performer = performer).apply { addView(root, index) }
|
||||
|
||||
/**
|
||||
* @see ViewGroup.addView
|
||||
* @see Hikageable
|
||||
@@ -39,7 +51,7 @@ inline fun ViewGroup.addView(
|
||||
index: Int = -1,
|
||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||
performer: HikagePerformer<ViewGroup.LayoutParams>
|
||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { addView(root, index) }
|
||||
) = addView<ViewGroup.LayoutParams>(index, factory, performer)
|
||||
|
||||
/**
|
||||
* @see ViewGroup.addView
|
||||
|
Reference in New Issue
Block a user