سؤال

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