RadioGroup und Layout kombinieren?

  • Antworten:12
  • Bentwortet
Gelöschter Account
  • Forum-Beiträge: 94

19.03.2010, 18:58:40 via Website

Hallo zusammen,

ich versuche gerade 4 RadioButtons zu einer RadioGroup zusammenzufassen und einigermaßen platzsparend anzuordnen. Leider ist für mich dieses Layouting bei Android völlig unverständlich... :(

1. Versuch:
Ergibt keine RadioGroup. Alle 4 RadioButtons lassen sich zusammen auswählen. s. Screenshot 01.
1<RadioGroup android:id="@+id/traintype" android:layout_width="fill_parent" android:layout_height="wrap_content">
2 <TableLayout android:id="@+id/TableLayout01"
3 >
4 <TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent" android:layout_height="wrap_content">
5
6 <RadioButton android:layout_height="wrap_content"
7 android:layout_width="fill_parent" android:id="@+id/radio_ice" android:text="ICE" android:layout_marginLeft="5sp"
8 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
9
10 <RadioButton android:layout_height="wrap_content"
11 android:layout_width="fill_parent" android:id="@+id/radio_ic_ec" android:text="IC/EC" android:layout_marginLeft="5sp"
12 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
13
14 </TableRow>
15 <TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
16
17 <RadioButton android:layout_height="wrap_content"
18 android:layout_width="fill_parent" android:id="@+id/radio_ir_d" android:text="IR/D" android:layout_marginLeft="5sp"
19 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
20
21 <RadioButton android:layout_height="wrap_content"
22 android:layout_width="fill_parent" android:id="@+id/radio_re_rb" android:text="RE/RB" android:layout_marginLeft="5sp"
23 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
24
25 </TableRow>
26 </TableLayout>
27 </RadioGroup>

2. Versuch:
Erzeugt auch keine RadioGroup, zerstört noch mehr. s. Screenshot 02
1<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content">
2
3 <RadioGroup android:id="@+id/traintype">
4
5 <TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent" android:layout_height="wrap_content">
6
7 <RadioButton android:layout_height="wrap_content"
8 android:layout_width="fill_parent" android:id="@+id/radio_ice" android:text="ICE" android:layout_marginLeft="5sp"
9 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
10
11 <RadioButton android:layout_height="wrap_content"
12 android:layout_width="fill_parent" android:id="@+id/radio_ic_ec" android:text="IC/EC" android:layout_marginLeft="5sp"
13 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
14
15 </TableRow>
16
17 <TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
18
19 <RadioButton android:layout_height="wrap_content"
20 android:layout_width="fill_parent" android:id="@+id/radio_ir_d" android:text="IR/D" android:layout_marginLeft="5sp"
21 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
22
23 <RadioButton android:layout_height="wrap_content"
24 android:layout_width="fill_parent" android:id="@+id/radio_re_rb" android:text="RE/RB" android:layout_marginLeft="5sp"
25 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
26
27 </TableRow>
28
29 </RadioGroup>
30
31 </TableLayout>

3. Versuch:
erzeugt zwar eine RadioGroup, verschwendet aber unglaublich viel Platz. s. Screenshot 03
1<RadioGroup android:id="@+id/traintype" android:layout_width="fill_parent" android:layout_height="wrap_content">
2
3 <RadioButton android:layout_height="wrap_content"
4 android:layout_width="fill_parent" android:id="@+id/radio_ice" android:text="ICE" android:layout_marginLeft="5sp"
5 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
6
7 <RadioButton android:layout_height="wrap_content"
8 android:layout_width="fill_parent" android:id="@+id/radio_ic_ec" android:text="IC/EC" android:layout_marginLeft="5sp"
9 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
10
11 <RadioButton android:layout_height="wrap_content"
12 android:layout_width="fill_parent" android:id="@+id/radio_ir_d" android:text="IR/D" android:layout_marginLeft="5sp"
13 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
14
15 <RadioButton android:layout_height="wrap_content"
16 android:layout_width="fill_parent" android:id="@+id/radio_re_rb" android:text="RE/RB" android:layout_marginLeft="5sp"
17 android:layout_marginRight="5sp" android:layout_marginTop="5sp" android:layout_marginBottom="0sp" />
18
19 </RadioGroup>

Hat einer ne Idee, wie ich meine RadioButtons zu einer RadioGroup zusammenfassen und gleichzeitig platzsparend anordnen (am besten alle nebeneinander) kann?

Martin

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

19.03.2010, 21:03:18 via Website

Versuch mal, beim 3. Versuch in das Group-Tag noch android:orientation="horizontal" einzufügen, dann sollten die Items neben- statt untereinander erscheinen.

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

19.03.2010, 22:44:52 via Website

Dann sieht's so aus: http://twitpic.com/19lwdv :(


EDIT: Ich hatte noch in den RadioButtons ein android:layout_width="fill_parent" drin. Das ist natürlich Quatsch...

— geändert am 19.03.2010, 22:47:51

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

19.03.2010, 23:29:48 via Website

Demnach funktioniert es jetzt wie gewünscht?

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

20.03.2010, 07:31:39 via App

es war etwas spät gestern...

jau, jetzt klappts wie gewünscht.

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

20.03.2010, 12:10:03 via Website

Prima :)

Vier in einer Reihe sieht nicht zu gedrängt aus?
Was sprach denn gegen einen Spinner?

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

20.03.2010, 14:46:05 via Website

Sieht etwas gedrängt aus. Ich feile noch am Feinlayout. :D

Ich finde nen Spinner nicht so schön um andere Werte als Zahlen auszuwählen...

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

22.03.2010, 15:32:08 via Website

and dev
Was sprach denn gegen einen Spinner?
Ich hatte Spinner missverstanden. :grin: Ich dachte ein Spinner ist sowas wie der Lautstärke-Regler. Nen Drop-Down hatte ich erst gesucht und nicht gefunden... :*) Asche auf mein Haupt...

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

22.03.2010, 20:16:55 via Website

Ich hatte Spinner missverstanden

Hatte mich schon gewundert, denn der Android-Spinner sieht ja gerade für (kurze) Zahlen nicht soooo überzeugend aus, weil der dann trotzdem fast die ganze Breite einnimmt, was jede Menge Leerraum produziert...

Ich habs vorhin im Market schon gesehen, die 4 Knöpfe gehen schon noch in die Zeile - wobei es vielleicht "ordentlicher" aussehen würde, wenn man sich mit PushButtons was basteln würde.

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

22.03.2010, 20:23:49 via Website

Ja, ich bin auch noch ein wenig unentschlossen... ich denk ich werd mal den Spinner austesten. Aber ich glaub ich bleib erstmal bei den Radios. ggf. bastel ich mir was mit ImageButtons...

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

22.03.2010, 23:20:17 via Website

ich denk ich werd mal den Spinner austesten. Aber ich glaub ich bleib erstmal bei den Radios

Klingt in der Tat etwas unentschlossen ;)


ggf. bastel ich mir was mit ImageButtons...

Du meinst den Text als Grafik zu machen und dann jeweils eine selektierte und eine deselektierte Variante davon?
...kommt mir ein bisschen mit Kanonen auf Spatzen geschossen vor ;)

Antworten
Gelöschter Account
  • Forum-Beiträge: 94

23.03.2010, 06:58:04 via Website

and dev
Du meinst den Text als Grafik zu machen und dann jeweils eine selektierte und eine deselektierte Variante davon?
...kommt mir ein bisschen mit Kanonen auf Spatzen geschossen vor ;)
Neee. Dann Bilder/Icons. Ggf. mit Text. Wäre aber ziemlich aufwendig. Werd mal mit meiner Grafikerin sprechen...

Antworten
San Blarnoi
  • Forum-Beiträge: 2.545

23.03.2010, 19:05:50 via Website

Wie würde denn zB ein Bild zu "IR" im Vergleich zu dem für "RE" aussehen?
Ich glaube, Text ist, hier schon die bessere Wahl.

Antworten