facebook twitter hatena line email

「Android/レイアウト/マージン」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==マージンサンプル== setMarginsを使う LinearLayout layout = new LinearLayout(activity); layout.setBackgroundColor(Color.argb(128, 16, 16, 16)); LinearLayout...」)
(相違点なし)

2018年11月1日 (木) 18:48時点における版

マージンサンプル

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);