XML Layout - ImageView

  • Antworten:1
Viktoria Dirry
  • Forum-Beiträge: 8

06.08.2012, 07:02:46 via Website

Hallo liebe Android Entwickler,

ich verzweifle mittlerweile an der Entwicklung eines Layouts.
An sich eine simple Sache, aber all meine Überlegungen führten nicht zur gewünschten Änderung.

Grundlegend wollte ich ein RelativeLayout mit:
  • TextView
  • ImageView
  • RadioButton Group mit vier RadioButtons
  • TextView
  • drei normale Buttons

erstellen. Allerdings wurde mir das Bild viel zu klein dargestellt.

Aufgrund zahlreicher versuche mit minHeight, maxHeigth, etc., die ebenfalls nicht funktioniert haben wählte ich statt dem RelativeLayout einen ScrollView und innerhalb dieses ScrollViews ein LinearLayout, aber wie man sich sicher denken kann wurde dann mein Layout vollkommen zerstört.

Das ganze soll in etwa (scrollable oder nicht ist egal) so aussehen, wie das unten angeführte Bild:

http://img5.fotos-hochladen.net/uploads/bildschirmfotoo7u3qaib58.png

Allerdings möchte ich nach der Überschrift und oberhalb der RadioButtons den besagten ImageView einfügen und das noch in einer halbwegs akzetablen Größe.

Meine erste Frage wäre, welches Layout würden Sie empfehlen?
Bitt berücksichtigen, dass das Layout in seinen Grundbestandteilen und der Anordnung gleich bleiben sollen.

Ich vermute stark, dass der Platz für das Bild einfach zu klein ist und es deshalb immer unbefriedigend dargestellt wird.

Hier der Code für das versuchte RelativeLayout:

1<?xml version="1.0" encoding="utf-8"?>
2<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:background="#334455"
6 android:orientation="vertical" >
7
8
9 <TextView
10 android:id="@+id/pictureQuestion"
11 android:layout_width="fill_parent"
12 android:layout_height="wrap_content"
13 android:gravity="center"
14 android:text="@+string/Test "
15 android:textColor="#FFFFFF"
16 android:background="#FF8C00"
17 android:textSize="8pt" />
18 <!-- android:contentDescription="@string/pictureText1" -->
19
20 <ImageView
21 android:id="@+id/picture"
22 android:layout_width="wrap_content"
23 android:layout_height="wrap_content"
24 android:layout_below="@+id/pictureQuestion"
25 android:layout_above="@+id/radioGroup_picture"
26 android:minHeight="100dp"
27 android:minWidth="100dp"
28 android:maxHeight="250dp"
29 android:maxWidth="250dp"
30 android:src="@drawable/bilderraetsel_verpackung" />
31
32 <!--android:maxHeight="500dip"
33 android:maxWidth="600dip"
34 android:layout_centerHorizontal="true"
35 android:layout_centerInParent="true"
36 android:adjustViewBounds="true"
37 android:scaleType="fitCenter"
38 android:scaleType="centerCrop"-->
39
40
41 <RadioGroup
42 android:id="@+id/radioGroup_picture"
43 android:layout_width="wrap_content"
44 android:layout_height="wrap_content"
45 android:layout_centerHorizontal="true"
46 android:layout_centerVertical="true"
47 android:orientation="vertical" >
48
49 <RadioButton
50 android:id="@+id/radioButtonOne"
51 android:layout_width="wrap_content"
52 android:layout_height="wrap_content"
53 android:layout_marginTop="100dp"
54 android:checked="false"
55 android:textColor="#FFFFFF" />
56
57 <RadioButton
58 android:id="@+id/radioButtonTwo"
59 android:layout_width="wrap_content"
60 android:layout_height="wrap_content"
61 android:checked="false"
62 android:textColor="#FFFFFF" />
63
64 <RadioButton
65 android:id="@+id/radioButtonThree"
66 android:layout_width="wrap_content"
67 android:layout_height="wrap_content"
68 android:checked="false"
69 android:textColor="#FFFFFF" />
70
71 <RadioButton
72 android:id="@+id/radioButtonFour"
73 android:layout_width="wrap_content"
74 android:layout_height="wrap_content"
75 android:checked="false"
76 android:textColor="#FFFFFF" />
77 </RadioGroup>
78 <Button
79 android:id="@+id/picture_button_joker"
80 android:layout_width="wrap_content"
81 android:layout_height="wrap_content"
82 android:layout_alignParentBottom="true"
83 android:layout_centerHorizontal="true"
84 android:layout_toLeftOf="@+id/picture_button_next_question"
85 android:layout_marginRight="10dp"
86 android:text="Joker"
87 android:textColor="#FF8C00" />
88
89 <Button
90 android:id="@+id/picture_button_cancle_game"
91 android:layout_width="wrap_content"
92 android:layout_height="wrap_content"
93 android:layout_alignParentBottom="true"
94 android:layout_marginLeft="10dp"
95 android:layout_toRightOf="@+id/picture_button_next_question"
96 android:text="Cancle"
97 android:textColor="#FF8C00" />
98
99 <Button
100 android:id="@+id/picture_button_next_question"
101 android:layout_width="wrap_content"
102 android:layout_height="wrap_content"
103 android:layout_alignParentBottom="true"
104 android:layout_centerHorizontal="true"
105 android:text="Next"
106 android:textColor="#FF8C00" />
107
108 <TextView
109 android:id="@+id/picture_Selected"
110 android:layout_width="wrap_content"
111 android:layout_height="wrap_content"
112 android:layout_above="@+id/picture_button_next_question"
113 android:layout_alignParentLeft="true"
114 android:layout_marginLeft="53dp"
115 android:textColor="#FFFFFF" />
116</RelativeLayout>

Wie limitiere ich am besten die Größe eines Bildes für die Darstellung im ImageView?
Oder ist es möglich den ImageView zu limitieren, wie oben definiert mit minHeight, etc. und das Bild beschränkt sich automatisch?

Denn ich möchte unterschiedliche Bilder darstellen, jedoch immer mit der gleich Größe.

Ich danke Ihnen für Ihre Unterstützung. ;-)

— geändert am 06.08.2012, 07:15:14

Antworten
Viktoria Dirry
  • Forum-Beiträge: 8

10.08.2012, 01:46:36 via Website

Weiss den Niemand weiter? :-(

Ich bräuchte dringend Hilfe.

Antworten