"Formular" Layout (TextView und EditText)

  • 8 Antworten
  • Letztes Antwortdatum
N

necromancer

Neues Mitglied
0
Hallo zusammen,

ich habe eine Frage an alle Layout Freaks unter euch.
Ich will mir eine "Einstellung" Seite bauen, dazu will ich links eine TextView und rechts eine Textbox.
Soweit so gut, jedoch ist das Problem dass die TextBox zwar schon rechts ist, aber direkt an der TextView klebt.
Jedoch sollte diese am rechten Rand kleben, damit es auch schön aussieht wenn ich das Natel drehe.

Ich habe DroidDraw : Graphical User Interface Editor for Android Cell Phone Development and Programming gefunden, dort habe ich gemerkt dass ich soetwas mit "android:layout_weight" erreichen kann.
Jedoch klebt der EditText weiterhin an der TextView.

Weiss jemand was noch fehlen würde an meinem Layout?

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget50"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableLayout
android:id="@+id/widget52"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TableRow
android:id="@+id/widget53"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<LinearLayout
android:id="@+id/widget54"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/widget55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="anzahl Bilder"
android:layout_weight="1"
>
</TextView>
<EditText
android:id="@+id/widget56"
android:layout_width="wrap_content"
android:layout_height="27px"
>
</EditText>
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>

Ich habe nach Layout Beispielen gesucht, jedoch finde ich nichts. Ich denke der Fehler liegt ihrgendwie an dem LinearLayout...

Gruss
necromancer
 
So sollte es aussehen:
Bildschirmfoto20100914um09.29.04.png


Und momentan sieht es so aus:
Bildschirmfoto20100914um09.29.19.png
 
<LinearLayout horizontal width:fill_parent>
<TextView>
<EditText layout_gravity=right>
</LinearLayout>

sollte das machen


edit oder aber auch ein tablelayout
 
Hallo swordi,

danke für die Hilfe, es funktioniert jetzt so halb:

Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
android:id="@+id/widget50"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableRow
android:id="@+id/myrow"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:id="@+id/widget47"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/widget48"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="anzahl Bilder"
android:textSize="20sp"
android:layout_weight="1"
>
</TextView>
<EditText
android:id="@+id/widget49"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EditText"
android:textSize="18sp"
android:layout_gravity="right"
>
</EditText>
</LinearLayout>
></TableRow>
</TableLayout>

Ohne die Rows zeigt er mir das Layout schön an (TextView nicht an EditText klebend).
füge ich jedoch die Row hinzu, kleben sie wieder aneinander.
Ich brauche jedoch die Row da dort noch weitere Einstellungen hineinkommen.
Weisst du welche Eigenschaft ich auf das Row noch setzen muss?

Danke & Gruss
Necro
 
Füg mal

android:stretchColumns="1"

als Attribut zum TableLayout hinzu. Dann kannst du mit gravity die Ausrichtung bestimmen.
 
Hallo BenOtto,

funktioniert auch mit

Code:
<TableLayout
android:id="@+id/widget50"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:stretchColumns="1"
>

nicht :sad:
 
Dann mach das LinearLayout innerhalb deiner TableRow noch weg. Die TableRow verhält sich ja schon wie ein LinearLayout.
 
Yess! :D
Ich wäre nie auf diesen Tag gekommen!

Vielen Dank!
 
Bitte sehr!
 
Zurück
Oben Unten