문제

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