質問

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

And i get: error: cannot find symbol method addRule(int)

Android Studio v 0.4.5

役に立ちましたか?

解決

Because you used ViewGroup.LayoutParams

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

but the method addRule is in the subclass RelativeLayout.LayoutParams implemented, so you may want to use instead:

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

see documentation of RelativeLayout.LayoutParams here

他のヒント

It should be

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top