Answers:
android.view.ViewGroup.MarginLayoutParams
有一种方法setMargins(left, top, right, bottom)
。直子类是:FrameLayout.LayoutParams
,LinearLayout.LayoutParams
和RelativeLayout.LayoutParams
。
使用例如LinearLayout
:
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
imageView.setLayoutParams(lp);
这以像素为单位设置边距。缩放使用
context.getResources().getDisplayMetrics().density
FrameLayout.LayoutParams
,也许其他:stackoverflow.com/questions/5401952/...
android:layout_centerHorizontal = "true"
和android:layout_alignParentBottom = "true"
在啥子办法可以做到这一点?