我有一个从TextureView扩展的customView。我希望这个customView始终是align_parent_right。
我在customView中的方法有以下代码:
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
setLayoutParams(layoutParams);
但是,customeView仍然是左对齐而不对齐。怎么改变才能正确对齐?
答案 0 :(得分:0)
以这种方式添加
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.addRule(RelativeLayout.LEFT_OF, R.id.leftViewIdHere);
setLayoutParams(layoutParams);