2016-11-17 49 views
0

我有一個從TextureView延伸的自定義視圖。我希望這個customView總是align_parent_right。TextureView以編程方式對齊父權

我裏面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); 
相關問題