質問編集履歴
2
更新修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -167,87 +167,3 @@
|
|
167
167
|
Android Studio 2.3.2
|
168
168
|
|
169
169
|
API 21: Android 5.0 (Lollipop)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
---
|
174
|
-
|
175
|
-
自己解決しました。<margin>タグは無いんですね。
|
176
|
-
|
177
|
-
```ここに言語を入力
|
178
|
-
|
179
|
-
public class MainActivity extends AppCompatActivity {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
@Override
|
188
|
-
|
189
|
-
protected void onCreate(Bundle savedInstanceState) {
|
190
|
-
|
191
|
-
super.onCreate(savedInstanceState);
|
192
|
-
|
193
|
-
setContentView(R.layout.activity_main);
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
LinearLayout layout = (LinearLayout)findViewById(R.id.layer);
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
// 追加1
|
202
|
-
|
203
|
-
int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
|
204
|
-
|
205
|
-
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(WC, WC);
|
206
|
-
|
207
|
-
layoutParams.setMargins(0, 25, 0, 50);
|
208
|
-
|
209
|
-
// 追加1ここまで
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
List<String> list = new ArrayList<>();
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
list.add("Hello 1");
|
218
|
-
|
219
|
-
list.add("Hello 2");
|
220
|
-
|
221
|
-
list.add("Hello 3");
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
for(int i = 0; i < list.size(); i++){
|
226
|
-
|
227
|
-
TextView textView = new TextView(this);
|
228
|
-
|
229
|
-
textView.setBackgroundResource(R.drawable.border);
|
230
|
-
|
231
|
-
textView.setText(list.get(i));
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
textView.setLayoutParams(layoutParams); // 追加2
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
layout.addView(textView);
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
}
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
```
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
![イメージ説明](f6ce2f731aa6d48065ae19e91ee43798.png)
|
1
自己解決しました。<margin>タグは無いんですね。
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,7 +98,7 @@
|
|
98
98
|
|
99
99
|
android:id="@+id/layout"
|
100
100
|
|
101
|
-
android:layout_width="
|
101
|
+
android:layout_width="wrap_content"
|
102
102
|
|
103
103
|
android:layout_height="0dp"
|
104
104
|
|
@@ -167,3 +167,87 @@
|
|
167
167
|
Android Studio 2.3.2
|
168
168
|
|
169
169
|
API 21: Android 5.0 (Lollipop)
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
---
|
174
|
+
|
175
|
+
自己解決しました。<margin>タグは無いんですね。
|
176
|
+
|
177
|
+
```ここに言語を入力
|
178
|
+
|
179
|
+
public class MainActivity extends AppCompatActivity {
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
@Override
|
188
|
+
|
189
|
+
protected void onCreate(Bundle savedInstanceState) {
|
190
|
+
|
191
|
+
super.onCreate(savedInstanceState);
|
192
|
+
|
193
|
+
setContentView(R.layout.activity_main);
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
LinearLayout layout = (LinearLayout)findViewById(R.id.layer);
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
// 追加1
|
202
|
+
|
203
|
+
int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
|
204
|
+
|
205
|
+
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(WC, WC);
|
206
|
+
|
207
|
+
layoutParams.setMargins(0, 25, 0, 50);
|
208
|
+
|
209
|
+
// 追加1ここまで
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
List<String> list = new ArrayList<>();
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
list.add("Hello 1");
|
218
|
+
|
219
|
+
list.add("Hello 2");
|
220
|
+
|
221
|
+
list.add("Hello 3");
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
for(int i = 0; i < list.size(); i++){
|
226
|
+
|
227
|
+
TextView textView = new TextView(this);
|
228
|
+
|
229
|
+
textView.setBackgroundResource(R.drawable.border);
|
230
|
+
|
231
|
+
textView.setText(list.get(i));
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
textView.setLayoutParams(layoutParams); // 追加2
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
layout.addView(textView);
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
![イメージ説明](f6ce2f731aa6d48065ae19e91ee43798.png)
|