Button über ScrollView legen

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

19.02.2011, 18:54:49 via Website

Hallo zusammen,

habe folgendes Problem. Undzwar habe ich oben ein textView, welches über dem ScrollView liegt, sodass der "Titel" immer sichtbar ist. Dies möchte ich nun auch ganz unten haben nur, dass dort buttons sein sollen, als eine Navigation. Leider habe ich es bis jetzt nicht geschafft, dass die Buttons drüber liegen und wenn, dass sie unten positioniert sind.

Habe schon vieles probiert, doch leider funtkionierte nichts. Ich hoffe ihr könnt mir weiterhelfen :)
Anbei die .xml und ein Screenshot.


1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 >
7 <TextView
8 android:layout_width="fill_parent"
9 android:background="@drawable/title_bg"
10 android:textColor="#ffffff"
11 android:gravity="center"
12 android:textSize="16px"
13 android:textStyle="bold"
14 android:shadowRadius="1"
15 android:shadowDy="-1"
16 android:shadowColor="#000000"
17 android:layout_height="44px"
18 android:text="@string/panoramen"
19 android:layout_alignParentTop="true"
20 />
21<Button
22 android:id="@+id/tagungsraum19"
23 android:layout_height="86px"
24 android:layout_width="50px"
25/>
26
27<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
28 android:orientation="vertical"
29 android:layout_width="fill_parent"
30 android:layout_height="fill_parent"
31 android:scrollbars="none"
32 >
33 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
34 android:orientation="vertical"
35 android:layout_width="fill_parent"
36 android:layout_height="fill_parent"
37 >
38<TextView
39 android:layout_width="fill_parent"
40 android:background="@drawable/pano_title_bg"
41 android:textColor="#ffffff"
42 android:gravity="left"
43 android:textSize="13px"
44 android:shadowRadius="1"
45 android:shadowDy="1"
46 android:shadowColor="#000000"
47 android:layout_height="33px"
48 android:text="@string/aquawell1"
49 android:paddingLeft="10px"
50 android:paddingTop="7px"
51 />
52<Button
53 android:id="@+id/aquawell1"
54 android:layout_height="86px"
55 android:layout_width="fill_parent"
56 android:background="@drawable/pano_001"
57/>
58<TextView
59 android:layout_width="fill_parent"
60 android:background="@drawable/pano_title_bg"
61 android:textColor="#ffffff"
62 android:gravity="left"
63 android:textSize="13px"
64 android:shadowRadius="1"
65 android:shadowDy="1"
66 android:shadowColor="#000000"
67 android:layout_height="33px"
68 android:text="@string/aquawell2"
69 android:paddingLeft="10px"
70 android:paddingTop="7px"
71 />
72<Button
73 android:id="@+id/aquawell2"
74 android:layout_height="86px"
75 android:layout_width="fill_parent"
76 android:background="@drawable/pano_002"
77/>
78<TextView
79 android:layout_width="fill_parent"
80 android:background="@drawable/pano_title_bg"
81 android:textColor="#ffffff"
82 android:gravity="left"
83 android:textSize="13px"
84 android:shadowRadius="1"
85 android:shadowDy="1"
86 android:shadowColor="#000000"
87 android:layout_height="33px"
88 android:text="@string/aquawell3"
89 android:paddingLeft="10px"
90 android:paddingTop="7px"
91 />
92<Button
93 android:id="@+id/aquawell3"
94 android:layout_height="86px"
95 android:layout_width="fill_parent"
96 android:background="@drawable/pano_003"
97/>
98<TextView
99 android:layout_width="fill_parent"
100 android:background="@drawable/pano_title_bg"
101 android:textColor="#ffffff"
102 android:gravity="left"
103 android:textSize="13px"
104 android:shadowRadius="1"
105 android:shadowDy="1"
106 android:shadowColor="#000000"
107 android:layout_height="33px"
108 android:text="@string/aquawell4"
109 android:paddingLeft="10px"
110 android:paddingTop="7px"
111 />
112<Button
113 android:id="@+id/aquawell4"
114 android:layout_height="86px"
115 android:layout_width="fill_parent"
116 android:background="@drawable/pano_004"
117/>
118<TextView
119 android:layout_width="fill_parent"
120 android:background="@drawable/pano_title_bg"
121 android:textColor="#ffffff"
122 android:gravity="left"
123 android:textSize="13px"
124 android:shadowRadius="1"
125 android:shadowDy="1"
126 android:shadowColor="#000000"
127 android:layout_height="33px"
128 android:text="@string/aquawell5"
129 android:paddingLeft="10px"
130 android:paddingTop="7px"
131 />
132<Button
133 android:id="@+id/aquawell5"
134 android:layout_height="86px"
135 android:layout_width="fill_parent"
136 android:background="@drawable/pano_005"
137/>
138<TextView
139 android:layout_width="fill_parent"
140 android:background="@drawable/pano_title_bg"
141 android:textColor="#ffffff"
142 android:gravity="left"
143 android:textSize="13px"
144 android:shadowRadius="1"
145 android:shadowDy="1"
146 android:shadowColor="#000000"
147 android:layout_height="33px"
148 android:text="@string/deluxe1"
149 android:paddingLeft="10px"
150 android:paddingTop="7px"
151 />
152<Button
153 android:id="@+id/deluxe1"
154 android:layout_height="86px"
155 android:layout_width="fill_parent"
156 android:background="@drawable/pano_006"
157/>
158<TextView
159 android:layout_width="fill_parent"
160 android:background="@drawable/pano_title_bg"
161 android:textColor="#ffffff"
162 android:gravity="left"
163 android:textSize="13px"
164 android:shadowRadius="1"
165 android:shadowDy="1"
166 android:shadowColor="#000000"
167 android:layout_height="33px"
168 android:text="@string/deluxe2"
169 android:paddingLeft="10px"
170 android:paddingTop="7px"
171 />
172<Button
173 android:id="@+id/deluxe2"
174 android:layout_height="86px"
175 android:layout_width="fill_parent"
176 android:background="@drawable/pano_007"
177/>
178<TextView
179 android:layout_width="fill_parent"
180 android:background="@drawable/pano_title_bg"
181 android:textColor="#ffffff"
182 android:gravity="left"
183 android:textSize="13px"
184 android:shadowRadius="1"
185 android:shadowDy="1"
186 android:shadowColor="#000000"
187 android:layout_height="33px"
188 android:text="@string/deluxe3"
189 android:paddingLeft="10px"
190 android:paddingTop="7px"
191 />
192
193<Button
194 android:id="@+id/deluxe3"
195 android:layout_height="86px"
196 android:layout_width="fill_parent"
197 android:background="@drawable/pano_008"
198/>
199</LinearLayout>
200</ScrollView>
201</LinearLayout>



Grüße,
malte

P.s. Das Bild ist mit PS hingepfuscht :P

Antworten
Bastian B
  • Forum-Beiträge: 47

21.02.2011, 08:43:33 via Website

Hi,

also mit einem LinearLayout wirst du da nicht sehr weit kommen, da dieses darauf ausgelegt ist Elemente neben- bzw. untereinander darzustellen.
Schau dir mal das RelativeLayout an, damit kannst du (relativ) frei deine Elemente positionieren...
Ganz grob müsste es dann ungefähr so aussehen:
1<RelativeLayout>
2
3<dein Header
4 alignParentTop="true"/>
5
6<dein ScrollView
7 BELOW="deinHeader"
8 BASELINE="deine Buttonleiste" />
9
10<deine ButtonLeiste
11 alignParentBottom="true"/>
12
13</RelativeLayout>

Die Möglichkeiten die View's realtiv zu positionieren schaust du dir am besten in der Doku selbst an. Da ist es sehr davon abhängig wie genau dein Layout aussehen soll. http://developer.android.com/reference/android/widget/RelativeLayout.html
Der code oben soll nur als Denkanstoß dienen... :)
Davon abgesehen: willst du wirklich die buttons am ende über den scrollview legen?!

Grüße...

Antworten