Wie man programmatisch die Breite und Höhe des Relative - Linear-layout in android?

Ich benötigte Laufzeit Abmessungen des Relativen/Linear Layout.

activity_home.xml:

<RelativeLayout
    android:id="@+id/rlParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</RelativeLayout>

HomeActivity.java:

private int width, height;

RelativeLayout rlParent = (RelativeLayout) findViewById(R.id.rlParent);

w = rlParent.getWidth();
h = rlParent.getHeight();

Log.i("Width-Height", width+"-"+height);

Bitte teilen Sie Ihre Gedanken.

InformationsquelleAutor Hiren Patel | 2013-12-12

Schreibe einen Kommentar