Question

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

Was it helpful?

Solution

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

OTHER TIPS

It should be

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top