Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

It should be

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top