- Главная
- Форум
- Программирование
- Программирование под Android
- SL4A - Scripting Layer For Android » Страница 35
SL4A - Scripting Layer For Android » Страница 35
-Программирование под Android
#342
2014-12-03T21:39:21Z21:39 3 дек 2014
Мужики! Помогите сделать макет интерфейса (снимок на скрине). Там видно, что у меня проблемы с долбаными весами - не могу никак точно отвесить лайоутам нужный вес, так, чтобы кнопки вверху и внизу макета были одинаковыми!
Вот структура макета:
1 | <?xml version = "1.0" |
2 | encoding = "utf-8" ?> |
3 | <LinearLayout |
4 | xmlns:android = "https://schemas.android.com/apk/res/android" |
5 | android: id = "@+id/cloth" |
6 | android:layout_width = "fill_parent" |
7 | android:layout_height = "fill_parent" |
8 | android:orientation = "vertical" > |
9 |
10 | <! - - Логотип HeaTPlaY - - > |
11 |
12 | <View |
13 | android: id = "@+id/up_bar" |
14 | android:layout_width = "fill_parent" |
15 | android:layout_height = "fill_parent" |
16 | android:layout_weight = "2" / > |
17 |
18 | <! - - Background верхней панели кнопок - - > |
19 |
20 | <LinearLayout |
21 | android:orientation = "horizontal" |
22 | android:layout_width = "fill_parent" |
23 | android:layout_weight = "0" |
24 | android:background = "#cccccc" > |
25 |
26 | <! - - Кнопки верхней панели - - > |
27 |
28 | <LinearLayout |
29 | android:orientation = "vertical" |
30 | android:layout_weight = "1" |
31 | android:background = "#000000" |
32 | android:layout_marginLeft = "1dp" |
33 | android:layout_marginBottom = "1dp" |
34 | android:layout_marginTop = "1dp" > |
35 |
36 | <ImageButton |
37 | android: id = "@+id/ic_menu_agenda" |
38 | android:gravity = "center" / > |
39 |
40 | < / LinearLayout> |
41 |
42 | <LinearLayout |
43 | android:orientation = "vertical" |
44 | android:layout_weight = "1" |
45 | android:background = "#000000" |
46 | android:layout_marginLeft = "1dp" |
47 | android:layout_marginBottom = "1dp" |
48 | android:layout_marginTop = "1dp" > |
49 |
50 | <ImageButton |
51 | android: id = "@+id/ic_menu_rotate" |
52 | android:layout_gravity = "center" / > |
53 |
54 | < / LinearLayout> |
55 |
56 | <LinearLayout |
57 | android:orientation = "vertical" |
58 | android:layout_weight = "1" |
59 | android:background = "#000000" |
60 | android:layout_marginLeft = "1dp" |
61 | android:layout_marginBottom = "1dp" |
62 | android:layout_marginTop = "1dp" > |
63 |
64 | <ImageButton |
65 | android: id = "@+id/ic_menu_recent_history" |
66 | android:layout_gravity = "center" / > |
67 |
68 | < / LinearLayout> |
69 |
70 | <LinearLayout |
71 | android:orientation = "vertical" |
72 | android:layout_weight = "1" |
73 | android:background = "#000000" |
74 | android:layout_marginRight = "1dp" |
75 | android:layout_marginLeft = "1dp" |
76 | android:layout_marginBottom = "1dp" |
77 | android:layout_marginTop = "1dp" > |
78 |
79 | <ImageButton |
80 | android: id = "@+id/ic_menu_search" |
81 | android:layout_gravity = "center" / > |
82 |
83 | < / LinearLayout> |
84 |
85 | < / LinearLayout> |
86 |
87 | <! - - ListView для списка медиа контента - - > |
88 |
89 | <ListView |
90 | android: id = "@+id/music_list" |
91 | android:layout_width = "fill_parent" |
92 | android:layout_height = "fill_parent" |
93 | android:layout_weight = "1" / > |
94 |
95 | <! - - Background нижней панели кнопок - - > |
96 |
97 | <LinearLayout |
98 | android:layout_below = "@id/body" |
99 | android:orientation = "horizontal" |
100 | android:layout_width = "fill_parent" |
101 | android:layout_weight = "0" |
102 | android:background = "#cccccc" > |
103 |
104 | <! - - Кнопки нижней панели - - > |
105 |
106 | <LinearLayout |
107 | android:orientation = "vertical" |
108 | android:layout_weight = "1" |
109 | android:background = "#000000" |
110 | android:layout_marginLeft = "1dp" |
111 | android:layout_marginBottom = "1dp" |
112 | android:layout_marginTop = "1dp" > |
113 |
114 | <ImageButton |
115 | android: id = "@+id/ic_media_previous" |
116 | android:gravity = "center" / > |
117 |
118 | < / LinearLayout> |
119 |
120 | <LinearLayout |
121 | android:orientation = "vertical" |
122 | android:layout_weight = "1" |
123 | android:background = "#000000" |
124 | android:layout_marginLeft = "1dp" |
125 | android:layout_marginBottom = "1dp" |
126 | android:layout_marginTop = "1dp" > |
127 |
128 | <ImageButton |
129 | android: id = "@+id/ic_media_rew" |
130 | android:layout_gravity = "center" / > |
131 |
132 | < / LinearLayout> |
133 |
134 | <LinearLayout |
135 | android:orientation = "vertical" |
136 | android:layout_weight = "1" |
137 | android:background = "#000000" |
138 | android:layout_marginLeft = "1dp" |
139 | android:layout_marginBottom = "1dp" |
140 | android:layout_marginTop = "1dp" > |
141 |
142 | <ImageButton |
143 | android: id = "@+id/ic_media_play" |
144 | android:layout_gravity = "center" / > |
145 |
146 | < / LinearLayout> |
147 |
148 | <LinearLayout |
149 | android:orientation = "vertical" |
150 | android:layout_weight = "1" |
151 | android:background = "#000000" |
152 | android:layout_marginRight = "1dp" |
153 | android:layout_marginLeft = "1dp" |
154 | android:layout_marginBottom = "1dp" |
155 | android:layout_marginTop = "1dp" > |
156 |
157 | <ImageButton |
158 | android: id = "@+id/ic_media_ff" |
159 | android:layout_gravity = "center" / > |
160 |
161 | < / LinearLayout> |
162 |
163 | <LinearLayout |
164 | android:orientation = "vertical" |
165 | android:layout_weight = "1" |
166 | android:background = "#000000" |
167 | android:layout_marginRight = "1dp" |
168 | android:layout_marginLeft = "1dp" |
169 | android:layout_marginBottom = "1dp" |
170 | android:layout_marginTop = "1dp" > |
171 |
172 | <ImageButton |
173 | android: id = "@+id/ic_media_next" |
174 | android:layout_gravity = "center" / > |
175 |
176 | < / LinearLayout> |
177 |
178 | < / LinearLayout> |
179 |
180 | < / LinearLayout> |
Если есть желание, можете предложить свой вариант.
Спасибо!
Дополнительный скрин #1 (606,04 Kb)
#343
2014-12-04T00:08:25Z00:08 4 дек 2014
Юра, это точно тот макет, не перепутал? Я глянул код и скрин, код еще далек от того, что на скрине, и не ясно, как именно надо - в коде под каждую кнопку рамка серая в 1dp, на скрине вроде прсто кнопки нативные... И неясно, как они вверху и внизу одинаковые будут, ведь вверху 4 в ряд, внизу- 5. Если только зазорами между ними или по краям сыграть. А вообще имхо лучше кнопкам этим не задавать размеры wrap_content, а например 48dp, ибо размеры их пляшут и между собой, и на разных прошивках.
#345
2014-12-04T09:53:59Z09:53 4 дек 2014
1 | # -*- coding: utf-8 -*- |
2 | import android |
3 | import sys |
4 | droid = android.Android() |
5 |
6 | layout = '''<?xml version="1.0" encoding="utf-8"?> |
7 | <LinearLayout |
8 | xmlns:android="https://schemas.android.com/apk/res/android" |
9 | android:id="@+id/cloth" |
10 | android:layout_width="fill_parent" |
11 | android:layout_height="fill_parent" |
12 | android:orientation="vertical"> |
13 |
14 | <!-- Логотип HeaTPlaY --> |
15 |
16 | <View |
17 | android:id="@+id/up_bar" |
18 | android:layout_width="fill_parent" |
19 | android:layout_weight="1" |
20 | android:layout_height="0dp"/> |
21 |
22 | <!-- Background верхней панели кнопок --> |
23 |
24 | <LinearLayout |
25 | android:orientation="horizontal" |
26 | android:layout_height="wrap_content" |
27 | android:layout_width="fill_parent"> |
28 |
29 | <!-- Кнопки верхней панели --> |
30 |
31 | <ImageButton |
32 | android:id="@+id/ic_menu_agenda" |
33 | android:layout_weight="1" |
34 | android:layout_width="0dp" |
35 | android:layout_height="48dp" |
36 | android:src="@android:drawable/ic_menu_agenda"/> |
37 | <ImageButton |
38 | android:id="@+id/ic_menu_rotate" |
39 | android:layout_weight="1" |
40 | android:layout_width="0dp" |
41 | android:layout_height="48dp" |
42 | android:src="@android:drawable/ic_menu_rotate"/> |
43 | <ImageButton |
44 | android:id="@+id/ic_menu_recent_history" |
45 | android:layout_weight="1" |
46 | android:layout_width="0dp" |
47 | android:layout_height="48dp" |
48 | android:src="@android:drawable/ic_menu_recent_history"/> |
49 | <ImageButton |
50 | android:id="@+id/ic_menu_search" |
51 | android:layout_weight="1" |
52 | android:layout_width="0dp" |
53 | android:layout_height="48dp" |
54 | android:src="@android:drawable/ic_menu_search"/> |
55 |
56 | </LinearLayout> |
57 |
58 | <!-- ListView для списка медиа контента --> |
59 |
60 | <ListView |
61 | android:id="@+id/music_list" |
62 | android:layout_width="fill_parent" |
63 | android:layout_height="0dp" |
64 | android:layout_weight="2"/> |
65 |
66 | <!-- Background нижней панели кнопок --> |
67 |
68 | <LinearLayout |
69 | android:layout_below="@id/body" |
70 | android:orientation="horizontal" |
71 | android:layout_height="wrap_content" |
72 | android:layout_width="fill_parent"> |
73 |
74 | <!-- Кнопки нижней панели --> |
75 |
76 | <ImageButton |
77 | android:id="@+id/ic_media_previous" |
78 | android:layout_weight="1" |
79 | android:layout_width="0dp" |
80 | android:layout_height="48dp" |
81 | android:src="@android:drawable/ic_media_previous"/> |
82 | <ImageButton |
83 | android:id="@+id/ic_media_rew" |
84 | android:layout_weight="1" |
85 | android:layout_width="0dp" |
86 | android:layout_height="48dp" |
87 | android:src="@android:drawable/ic_media_rew"/> |
88 | <ImageButton |
89 | android:id="@+id/ic_media_play" |
90 | android:layout_weight="1" |
91 | android:layout_width="0dp" |
92 | android:layout_height="48dp" |
93 | android:src="@android:drawable/ic_media_play"/> |
94 | <ImageButton |
95 | android:id="@+id/ic_media_ff" |
96 | android:layout_weight="1" |
97 | android:layout_width="0dp" |
98 | android:layout_height="48dp" |
99 | android:src="@android:drawable/ic_media_ff"/> |
100 | <ImageButton |
101 | android:id="@+id/ic_media_next" |
102 | android:layout_weight="1" |
103 | android:layout_width="0dp" |
104 | android:layout_height="48dp" |
105 | android:src="@android:drawable/ic_media_next"/> |
106 |
107 | </LinearLayout> |
108 |
109 | </LinearLayout>''' |
110 |
111 |
112 |
113 | def main(): |
114 | droid.fullShow(layout) |
115 | droid.fullSetList( 'music_list' , [ '1' ] * 20 ) |
116 | while True : |
117 | signal = droid.eventWait().result |
118 | if signal[ "name" ] = = "key" and signal[ "data" ][ "key" ] = = "4" : |
119 | droid.fullDismiss() |
120 | sys.exit() |
121 | main() |
вот накидал, глянь
#347
2014-12-04T12:03:28Z12:03 4 дек 2014
Наврядли у меня лучше получилось)). Ты привел макет, но еще кой-какие свойства ты видимо задавал из .py скрипта, всвязи с чем я не до конца понял конечный вид. Я не понял, зачем каждая кнопка обворачивалась в linear layout с рамкой 1дп, также почему ты пытался задать такой большой вес логотипу (там картинка планировалась?). Вобщем сделал чтоб было похоже на пример на скрине. Вобщем, вот что выдавала та разметка, что ты выложил, чтоб было понятно, почему я не въехал
Дополнительный скрин #1 (12,58 Kb)
#349
2014-12-06T21:08:57Z21:08 6 дек 2014
Мужикт, еще вопрос... Прикрепил два скрина: на первом вверху экрана присутствуют логотип, полоса прогресс бара и информационное поле с текстом "Исполнитель". После клика по треку в центре экрана, в информационном поле пояыляется строка: "Название трека, имя исполнителя, нязвание альбома, стиль трека". На втором сирине видно, что конкретно у меня не получается: Информационное поле при добавлении большой строки работает, как wrap_content, а мне нужно однострочное поле. Переюзал все параметры, не получается, как следует. Ниже привожу код макета.
1 | <?xml version = "1.0" |
2 | encoding = "utf-8" ?> |
3 | <LinearLayout |
4 | xmlns:android = "https://schemas.android.com/apk/res/android" |
5 | android: id = "@+id/cloth" |
6 | android:layout_width = "fill_parent" |
7 | android:layout_height = "fill_parent" |
8 | android:orientation = "vertical" > |
9 |
10 | <LinearLayout |
11 | android:orientation = "vertical" |
12 | android:layout_width = "fill_parent" |
13 | android:layout_height = "fill_parent" |
14 | android:background = "#000000" |
15 | android:layout_weight = "2" > |
16 |
17 | <! - - Логотип HeaTPlaY - - > |
18 |
19 | <View |
20 | android: id = "@+id/up_bar" |
21 | android:layout_width = "fill_parent" |
22 | android:layout_weight = "8" |
23 | android:layout_marginLeft = "5dp" |
24 | android:layout_marginRight = "5dp" |
25 | android:layout_marginBottom = "5dp" / > |
26 |
27 | <! - - Прогресс бар трека - - > |
28 |
29 | <View |
30 | android: id = "@+id/pos_line" |
31 | android:layout_weight = "14" |
32 | android:layout_width = "fill_parent" |
33 | android:background = "#cccccc" |
34 | android:layout_marginLeft = "5dp" |
35 | android:layout_marginRight = "5dp" |
36 | android:layout_marginBottom = "5dp" / > |
37 |
38 | <! - - Информационное поле - - > |
39 |
40 | <TextView |
41 | android: id = "@+id/track_info" |
42 | android:layout_weight = "0" |
43 | android:layout_width = "fill_parent" |
44 | android:layout_marginLeft = "5dp" |
45 | android:layout_marginRight = "5dp" |
46 | android:layout_marginBottom = "5dp" |
47 | android:background = "#cccccc" |
48 | android:textColor = "#000000" |
49 | android:text = "Исполнитель" / > |
50 |
51 | < / LinearLayout> |
52 |
53 | <! - - Background верхней панели кнопок - - > |
54 |
55 | <LinearLayout |
56 | android:orientation = "horizontal" |
57 | android:layout_width = "fill_parent" |
58 | android:layout_weight = "0" |
59 | android:background = "#cccccc" > |
60 |
61 | <! - - Кнопки верхней панели - - > |
62 |
63 | <LinearLayout |
64 | android:orientation = "vertical" |
65 | android:layout_weight = "1" |
66 | android:background = "#000000" |
67 | android:layout_marginLeft = "1dp" |
68 | android:layout_marginBottom = "1dp" |
69 | android:layout_marginTop = "1dp" > |
70 |
71 | <ImageButton |
72 | android: id = "@+id/ic_menu_agenda" |
73 | android:layout_height = "48dp" |
74 | android:gravity = "center" / > |
75 |
76 | < / LinearLayout> |
77 |
78 | <LinearLayout |
79 | android:orientation = "vertical" |
80 | android:layout_weight = "1" |
81 | android:background = "#000000" |
82 | android:layout_marginLeft = "1dp" |
83 | android:layout_marginBottom = "1dp" |
84 | android:layout_marginTop = "1dp" > |
85 |
86 | <ImageButton |
87 | android: id = "@+id/ic_menu_rotate" |
88 | android:layout_height = "48dp" |
89 | android:layout_gravity = "center" / > |
90 |
91 | < / LinearLayout> |
92 |
93 | <LinearLayout |
94 | android:orientation = "vertical" |
95 | android:layout_weight = "1" |
96 | android:background = "#000000" |
97 | android:layout_marginLeft = "1dp" |
98 | android:layout_marginBottom = "1dp" |
99 | android:layout_marginTop = "1dp" > |
100 |
101 | <ImageButton |
102 | android: id = "@+id/ic_menu_recent_history" |
103 | android:layout_height = "48dp" |
104 | android:layout_gravity = "center" / > |
105 |
106 | < / LinearLayout> |
107 |
108 | <LinearLayout |
109 | android:orientation = "vertical" |
110 | android:layout_weight = "1" |
111 | android:background = "#000000" |
112 | android:layout_marginRight = "1dp" |
113 | android:layout_marginLeft = "1dp" |
114 | android:layout_marginBottom = "1dp" |
115 | android:layout_marginTop = "1dp" > |
116 |
117 | <ImageButton |
118 | android: id = "@+id/ic_menu_search" |
119 | android:layout_height = "48dp" |
120 | android:layout_gravity = "center" / > |
121 |
122 | < / LinearLayout> |
123 |
124 | < / LinearLayout> |
125 |
126 | <! - - ListView для списка медиа контента - - > |
127 |
128 | <ListView |
129 | android: id = "@+id/music_list" |
130 | android:layout_width = "fill_parent" |
131 | android:layout_height = "fill_parent" |
132 | android:layout_weight = "1" / > |
133 |
134 | <! - - Background нижней панели кнопок - - > |
135 |
136 | <LinearLayout |
137 | android:layout_below = "@id/body" |
138 | android:orientation = "horizontal" |
139 | android:layout_width = "fill_parent" |
140 | android:layout_weight = "0" |
141 | android:background = "#cccccc" > |
142 |
143 | <! - - Кнопки нижней панели - - > |
144 |
145 | <LinearLayout |
146 | android:orientation = "vertical" |
147 | android:layout_weight = "1" |
148 | android:background = "#000000" |
149 | android:layout_marginLeft = "1dp" |
150 | android:layout_marginBottom = "1dp" |
151 | android:layout_marginTop = "1dp" > |
152 |
153 | <ImageButton |
154 | android: id = "@+id/ic_media_previous" |
155 | android:layout_height = "48dp" |
156 | android:gravity = "center" / > |
157 |
158 | < / LinearLayout> |
159 |
160 | <LinearLayout |
161 | android:orientation = "vertical" |
162 | android:layout_weight = "1" |
163 | android:background = "#000000" |
164 | android:layout_marginLeft = "1dp" |
165 | android:layout_marginBottom = "1dp" |
166 | android:layout_marginTop = "1dp" > |
167 |
168 | <ImageButton |
169 | android: id = "@+id/ic_media_rew" |
170 | android:layout_height = "48dp" |
171 | android:layout_gravity = "center" / > |
172 |
173 | < / LinearLayout> |
174 |
175 | <LinearLayout |
176 | android:orientation = "vertical" |
177 | android:layout_weight = "1" |
178 | android:background = "#000000" |
179 | android:layout_marginLeft = "1dp" |
180 | android:layout_marginBottom = "1dp" |
181 | android:layout_marginTop = "1dp" > |
182 |
183 | <ImageButton |
184 | android: id = "@+id/ic_media_play" |
185 | android:layout_height = "48dp" |
186 | android:layout_gravity = "center" / > |
187 |
188 | < / LinearLayout> |
189 |
190 | <LinearLayout |
191 | android:orientation = "vertical" |
192 | android:layout_weight = "1" |
193 | android:background = "#000000" |
194 | android:layout_marginRight = "1dp" |
195 | android:layout_marginLeft = "1dp" |
196 | android:layout_marginBottom = "1dp" |
197 | android:layout_marginTop = "1dp" > |
198 |
199 | <ImageButton |
200 | android: id = "@+id/ic_media_ff" |
201 | android:layout_height = "48dp" |
202 | android:layout_gravity = "center" / > |
203 |
204 | < / LinearLayout> |
205 |
206 | <LinearLayout |
207 | android:orientation = "vertical" |
208 | android:layout_weight = "1" |
209 | android:background = "#000000" |
210 | android:layout_marginRight = "1dp" |
211 | android:layout_marginLeft = "1dp" |
212 | android:layout_marginBottom = "1dp" |
213 | android:layout_marginTop = "1dp" > |
214 |
215 | <ImageButton |
216 | android: id = "@+id/ic_media_next" |
217 | android:layout_height = "48dp" |
218 | android:layout_gravity = "center" / > |
219 |
220 | < / LinearLayout> |
221 |
222 | < / LinearLayout> |
223 |
224 | < / LinearLayout> |
- «
- 1
- 2
- --
- 34
- 35
- 36
- 37
- »
Авторизуйтесь на сайте для написания ответа.