「Android/レイアウト/マージン」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==マージンサンプル== setMarginsを使う LinearLayout layout = new LinearLayout(activity); layout.setBackgroundColor(Color.argb(128, 16, 16, 16)); LinearLayout...」) |
(→マージンサンプル) |
||
| 行10: | 行10: | ||
txt.setText("0:00"); | txt.setText("0:00"); | ||
layout.addView(txt, lp); | layout.addView(txt, lp); | ||
| + | |||
| + | <pre> | ||
| + | <FrameLayout | ||
| + | android:layout_width="match_parent" | ||
| + | android:layout_height="match_parent" | ||
| + | android:paddingBottom="20dp" | ||
| + | android:paddingLeft="40dp" | ||
| + | android:paddingRight="20dp" | ||
| + | android:paddingTop="40dp" | ||
| + | android:colo | ||
| + | /> | ||
| + | </pre> | ||
2019年5月10日 (金) 17:12時点における版
マージンサンプル
setMarginsを使う
LinearLayout layout = new LinearLayout(activity); layout.setBackgroundColor(Color.argb(128, 16, 16, 16)); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WC, WC); lp.setMargins(10, 20, 30, 40); // left, top, right, bottom
TextView txt = new TextView(activity);
txt.setTextColor(Color.WHITE);
txt.setText("0:00");
layout.addView(txt, lp);
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="20dp"
android:paddingLeft="40dp"
android:paddingRight="20dp"
android:paddingTop="40dp"
android:colo
/>
