我尝试按屏幕尺寸制作文本之间的边距。
除了一个 TextView 之外,它运行良好。
只有mon
右边距不起作用。
感谢您的帮助:)
这是代码和图片:
public void setDaysBar()
{
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
if (android.os.Build.VERSION.SDK_INT >= 13)
{
Point size = new Point();
display.getSize(size);
width = size.x;
}
else
width = display.getHeight();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
sun.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView3);
lp.setMargins(0, 0, width/6, 0);
mon.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView2);
lp.setMargins(0, 0, width/6, 0);
tue.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView9);
lp.setMargins(0, 0, width/6, 0);
wed.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView1);
lp.setMargins(0, 0, width/6, 0);
thu.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView4);
lp.setMargins(0, 0, width/6, 0);
fri.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.RIGHT_OF, R.id.textView6);
lp.setMargins(0, 0, width/6, 0);
sat.setLayoutParams(lp);
}