2013-12-22 28 views
0

我的主要(層次結構中最高)佈局是RelativeLayout。在它內部,我以編程方式創建一個LinearLayout。它必須具有「低於」button1的屬性。我知道如何使用addRule()將其添加到RelativeLayout.LayoutParams,但LinearLayout.LayoutParams沒有該選項。將「下方」添加到線性佈局LayoutParams

+0

參考[this](http://stackoverflow.com/questions/3277196/can-i-set-androidlayout-below-at-runtime-programmatically) – Manishika

回答

2

您不能將以下屬性設置爲LinearLayout。最大可以給定垂直或水平方向類型。 例如

LinearLayout layout = /* ... */; 
layout.setOrientation(LinearLayout.VERTICAL); 
//OR 
layout.setOrientation(LinearLayout.HORIZONTAL); 
1

LinearLayout是孩子的父母RelativeLayoutLayoutParams指定其父代中的孩子的佈局,因此在這種情況下,用於RelativeLayout父母的正確的LayoutParamsRelativeLayout.LayoutParams

相關問題