TextureView以编程方式对齐父权

时间:2016-11-17 14:01:22

标签: android layoutparams textureview

我有一个从TextureView扩展的customView。我希望这个customView始终是align_parent_right。

我在customView中的方法有以下代码:

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
setLayoutParams(layoutParams);

但是,customeView仍然是左对齐而不对齐。怎么改变才能正确对齐?

1 个答案:

答案 0 :(得分:0)

以这种方式添加

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.addRule(RelativeLayout.LEFT_OF, R.id.leftViewIdHere);
setLayoutParams(layoutParams);