mirror of
https://github.com/BetterAndroid/Hikage.git
synced 2025-09-05 10:15:37 +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) {
|
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addView {
|
addView<FrameLayout.LayoutParams> {
|
||||||
TextView {
|
TextView {
|
||||||
text = "Hello, World!"
|
text = "Hello, World!"
|
||||||
textSize = 16f
|
textSize = 16f
|
||||||
|
@@ -217,7 +217,7 @@ root.addView {
|
|||||||
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
class CustomView(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addView {
|
addView<FrameLayout.LayoutParams> {
|
||||||
TextView {
|
TextView {
|
||||||
text = "Hello, World!"
|
text = "Hello, World!"
|
||||||
textSize = 16f
|
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.HikagePerformer
|
||||||
import com.highcapable.hikage.core.base.Hikageable
|
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 ViewGroup.addView
|
||||||
* @see Hikageable
|
* @see Hikageable
|
||||||
@@ -39,7 +51,7 @@ inline fun ViewGroup.addView(
|
|||||||
index: Int = -1,
|
index: Int = -1,
|
||||||
factory: HikageFactoryBuilder.() -> Unit = {},
|
factory: HikageFactoryBuilder.() -> Unit = {},
|
||||||
performer: HikagePerformer<ViewGroup.LayoutParams>
|
performer: HikagePerformer<ViewGroup.LayoutParams>
|
||||||
) = Hikageable(context = context, factory = factory, performer = performer).apply { addView(root, index) }
|
) = addView<ViewGroup.LayoutParams>(index, factory, performer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ViewGroup.addView
|
* @see ViewGroup.addView
|
||||||
|
Reference in New Issue
Block a user