現在、mypopup という名前のポップアップ ウィンドウを含む Android アプリケーションを実行しています。画像ボタンと 4 つのテキストビューが含まれています。ポップアップ ウィンドウを、margin top、margin bottom、margin left、margin right パラメータに合わせて動的に配置したい..私のコードでは、setmargin メソッドが機能していません..誰か助けてください...
4117 次
2 に答える
0
使用しているレイアウトによって異なります。以下の例では、RelativeLayout を LinearLayout に配置します。
LinearLayout linearLayoutParent;
RelativeLayout relativeLayout;
RelativeLayout.LayoutParams margin = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
margin.setMargins(0, 0, 0, 7); //7px bottom margin
//create the linear and the relative layouts
//...add other stuff here...
// Add view with its margins
linearLayoutParent.addView(relativeLayout, margin);
于 2013-07-24T06:06:16.037 に答える