Android Forum » Android Developer Forum » Android Entwickler Forum » Anordnung - brauche hilfe!

Anordnung - brauche hilfe!

Anordnung - brauche hilfe!
verfasst am 12.07.2011 16:41:02 — geändert am 12.07.2011 16:41:27
Hiho!
Ich brauche hilfe beim Anordnen von Text und Bild. Erst hatte ich es so, dass es ging, aber das war total umständlich um mit ganz vielen Views Ineinander geschachtelt. Jetzt wollte ich das ganze einfach mit einem TableLayout machen und da darin dann 4 Spalten wobei die eine rechts und die andere Links angeordnet ist. Leider bewegt sich mein Bild aber nicht nach Links.
Ich habe auch eine Spalten Überschrift der ich layout_span 4 gegeben habe. Wenn diese länger wird, wird auch die erste Spalte länger, dabei soll der Text doch alle 4 Spalten füllen und keine Auswirkungen auf die größe der 1. Spalte haben.
Vielleicht hat ja jemand einen Tipp. Als es funktionierte hatte ich jede meiner Zeilen noch mal in Linear Layouts gepackt. Aber irgendwie ist das ja auch nicht sinnvoll. Auf dem Bild seht ihr wie es aussieht. Ich finde das ist nicht schön.

1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="fill_parent"
4 android:layout_height="fill_parent">
5 <TextView
6 android:layout_width="wrap_content"
7 android:layout_height="wrap_content"
8 android:text="TextView"
9 android:id="@+id/spiel_id" />
10 <TableLayout
11 android:stretchColumns="0,1"
12 android:layout_height="wrap_content"
13 android:id="@+id/tableLayout1"
14 android:layout_width="fill_parent">
15 <TableRow
16 android:layout_gravity="center"
17 android:id="@+id/tableRow1"
18 android:layout_width="fill_parent"
19 android:layout_height="wrap_content">
20 <TextView
21 android:textAppearance="?android:attr/textAppearanceLarge"
22 android:layout_gravity="center"
23 android:text=""
24 android:id="@+id/heim_m"
25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content" />
27 <TextView
28 android:textAppearance="?android:attr/textAppearanceLarge"
29 android:layout_width="wrap_content"
30 android:text=""
31 android:layout_height="wrap_content"
32 android:layout_gravity="center"
33 android:id="@+id/gast_m" />
34 </TableRow>
35 </TableLayout>
36 <ScrollView
37 android:id="@+id/scrollView1"
38 android:layout_width="fill_parent"
39 android:layout_height="wrap_content">
40
41 <LinearLayout
42 android:orientation="vertical"
43 android:layout_width="fill_parent"
44 android:id="@+id/linearLayout10"
45 android:layout_height="fill_parent">
46 <TableLayout
47 android:layout_width="fill_parent"
48 android:layout_height="wrap_content"
49 android:id="@+id/tableLayout2">
50
51 <TableRow
52 android:layout_width="fill_parent"
53 android:layout_height="wrap_content"
54 android:id="@+id/tr_name_platz"
55 android:gravity="center">
56 <TextView android:layout_span="4"
57 android:textAppearance="?android:attr/textAppearanceLarge"
58 android:layout_width="fill_parent"
59 android:id="@+id/textView1"
60 android:text="@string/table"
61 android:layout_height="wrap_content"
62 android:gravity="center_horizontal"></TextView>
63 </TableRow>
64
65 <TableRow
66 android:layout_width="fill_parent"
67 android:layout_height="wrap_content"
68 android:id="@+id/tr_tabellenplatz"
69 android:layout_gravity="center_vertical|left">
70 <TextView
71 android:id="@+id/tv_tabellenplatz_h"
72 android:layout_height="wrap_content"
73 android:layout_width="fill_parent"
74 android:text="@string/goals"
75 android:layout_gravity="center_horizontal"
76 android:gravity="center"></TextView>
77 <ImageView
78 android:layout_height="wrap_content"
79 android:src="@drawable/down"
80 android:id="@+id/iv_tabellenplatz_h"
81 android:layout_width="wrap_content"
82 android:layout_gravity="left"
83 android:baselineAlignBottom="true"></ImageView>
84 <TextView
85 android:id="@+id/tv_tabellenplatz_g"
86 android:layout_height="wrap_content"
87 android:layout_width="fill_parent"
88 android:gravity="right"
89 android:text="@string/Platz"></TextView>
90 <ImageView
91 android:layout_width="wrap_content"
92 android:layout_height="wrap_content"
93 android:id="@+id/iv_tabellenplatz_g"></ImageView>
94 </TableRow>
Antworten mit Zitat Antworten Link ±0     (0 Stimmen)
User-Foto
Gelöschter Account
RE: Anordnung - brauche hilfe!
verfasst am 12.07.2011 20:52:20
Beim TableLayout hast Du relativ wenig Kontrolle über die Anordnung. Nimm einfach ein LinearLayout und schachtele darin pro Zeile weitere LinearLayouts. Dahinein kommen dann Deine Views. Das horizontale Größenverhältnis kannst Du dann mit layout_weight bei den Views angeben.

Der komplette Verzicht auf TableLayouts hat mir irgendwann das Leben erheblich einfacher gemacht.

Gruß
Harald

-----
Tankbuch Mobil | Wuala Music Player | Wuala Sync | GaCoMo

Antworten mit Zitat Antworten Link ±0     (0 Stimmen)
RE: Anordnung - brauche hilfe!
verfasst am 12.07.2011 20:58:35
Ok werde ich dann mal so versuchen.
Antworten mit Zitat Antworten Link ±0     (0 Stimmen)