2014-03-02 89 views
1
ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight); 
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 

,我得到:錯誤:無法找到符號方法addRule(INT)的Android Studio無法解析法addRule()

的Android Studio版本0.4.5

+0

你有什麼進口的? – wlk

回答

2

因爲使用ViewGroup.LayoutParams

ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight); 
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 

但該方法addRule是在子類RelativeLayout.LayoutParams實現的,所以你可能要改用:

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight); 
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 

看到documentation of RelativeLayout.LayoutParams here

2

應該

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight); 
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 
相關問題