動的にビューのマージンを変更する レイアウトからではなくコード中でビューのマージンを変更したいという場合があると思います。 その場合はMarginLayoutParamsを取得し、それを介してビューのマージンを変更します。 例えば、テキストビューのマージンをコード中から変更するには次のようにします。 package com.MyApp.myapp; import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.LayoutParams; import android.widget.TextView; public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) {