¿Puede darme un ejemplo muy simple de agregar vista hija programáticamente al RelativeLayout
en una posición determinada?¿Cómo agregar una vista programmattically a RelativeLayout?
Por ejemplo, para reflejar el siguiente código XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="107dp"
android:layout_marginTop="103dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
No entiendo cómo crear un RelativeLayout.LayoutParams
instancia apropiada.
Lo siento, la misma pregunta: ¿dónde aprendiste acerca del constructor 'RelativeLayout.LayoutParams' sin un' Contexto' como primer parámetro? –
@SuzanCioc Ver la edición anterior – JRaymond
Ah, lo siento fue pensar que el ancho y la altura deberían ser valores exactos. –