Programmatically inflated layout with Kotlin Android Extensions
From the docs you linked:
If we want to call the synthetic properties on View (useful in adapter classes), we should also import
kotlinx.android.synthetic.main.activity_main.view.*.
That is, import kotlinx.android.synthetic.main.layout.view.*
as well to load the View
extension properties.
Then:
val view = LayoutInflater.from(context).inflate(...)
view.tvErrorTitle.text = "test"
In kotlin you can try this to inflate layout inside linear layout using databinding
val inflater: LayoutInflater = LayoutInflater.from(activity).context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val mBindingDeno: LayoutDenominationBinding =
DataBindingUtil.inflate(
inflater, R.layout.layout_denomination, null, false
)
layout.addView(mBindingDeno.root)
Here layout is your LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:nestedScrollingEnabled="true"
android:visibility="gone">
<LinearLayout
android:id="@+id/linear_denomination"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</ScrollView>
It returns a view inflated:
layoutInflater.inflate(R.layout.your_layout, null)
See, you can replace this LayoutInflater.from(context)
with this layoutInflater
when your class extend from a Context superclass