Android RelativeLayout 代码动态添加居中控件

LottieAnimationView lottieAnimationView = new LottieAnimationView(this, null);
lottieAnimationView.setImageAssetsFolder(“images”);
lottieAnimationView.setAnimation(R.raw.data);
lottieAnimationView.loop(true);
lottieAnimationView.playAnimation();
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.height = 1500;
params.width = 760;
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
root.addView(lottieAnimationView, params);

你可能感兴趣的:(layout)