Android/レイアウト/マージン
提供: 初心者エンジニアの簡易メモ
マージンサンプル
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"
/>
