Here's my EditText
<?xml version="1.0" encoding="utf-8"?>
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="3dp"
android:text=""
android:ems="10"
android:gravity="center_vertical"
android:imeOptions="actionNext"
android:maxLines="1"
android:background="@drawable/profile_edt_round_corners"
android:drawablePadding="5dp"
android:textSize="14sp"
android:hint=""
tools:ignore="RtlSymmetry"
android:textColor="#4a4a4a"/>
Inflating the view
private fun getRoundedEditText() =
layoutInflater.inflate(R.layout.v_rounded_corners, null) as EditText
Setting the values
private fun addDataToParents() {
val editTextView = getRoundedEditText()
editTextView.setText("Parent 1")
ll_parents_guardian_container.addView(editTextView)
val editTextView2 = getRoundedEditText()
editTextView2.setText("Parent 2")
ll_parents_guardian_container.addView(editTextView2)
}
Where ll_parents_guardian_container
is
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ll_parents_guardian_container"
android:orientation="vertical">
</LinearLayout>
However the layout_marginTop
and layout_height
which i had already defined in XML is not reflected there.