android 控件之间的间距怎么调整
1个回答
展开全部
示例代码(添加三张图片,并设置相互之间的间距):
for(int i=0;i<3;i++){
imageView = new ImageView(this);
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setMargins(0, 0, 20, 10); //设置间距
imageView.setLayoutParams(layout);
imageView.setBackgroundResource(R.drawable.page_on);
}
for(int i=0;i<3;i++){
imageView = new ImageView(this);
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setMargins(0, 0, 20, 10); //设置间距
imageView.setLayoutParams(layout);
imageView.setBackgroundResource(R.drawable.page_on);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询