Zum hinzufügen einer Ansicht programmgesteuert zu RelativeLayout?

Können Sie mir ein sehr einfaches Beispiel für das hinzufügen der untergeordneten Ansicht programmgesteuert zu RelativeLayout an einer bestimmten position?

Zum Beispiel, entsprechend dem folgenden XML-Code:

<?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" />

Ich verstehe nicht, wie man erstellen Sie eine entsprechende RelativeLayout.LayoutParams Instanz.

InformationsquelleAutor Suzan Cioc | 2012-05-02
Schreibe einen Kommentar