我在ImageViews
中有一些RelativeLayout
,我在setScaleX
上使用了setScaleY
和Imageviews
方法。我还在ImageViews
的左侧设置了50的边距,但是当图像缩放时,它肯定不是50的边距。
如果我要将图像缩放回来,边距将是完美的,因此似乎RelativeLayout
可能不会更新其元素。我查看了各种在线课程和指南,但无法找到任何帮助我的内容
编辑:
RelativeLayout tl = (RelativeLayout) v.findViewById(R.id.l1);
tl.setBackgroundColor(Color.RED);
numberOfBells
float scale = (float) (1 - ( (int) numberOfBells/2) * 0.3);
final ImageView imageTopL = new ImageView(getActivity());
final ImageView imageTopR = new ImageView(getActivity());
imageTopL.setId(1);
imageTopL.setImageResource(R.drawable.bell_dl_256);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
imageTopL.setScaleX(scale);
imageTopL.setScaleY(scale);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params1.setMargins(50,10,0,0);
imageTopL.setLayoutParams(params1);
imgViews.add(imageTopL);
imageTopR.setId(2);
imageTopR.setImageResource(R.drawable.bell_dr_256);
imageTopR.setScaleX(scale);
imageTopR.setScaleY(scale);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params2.setMargins(0,10,50,0);
imageTopR.setLayoutParams(params2);
imgViews.add(imageTopR);