• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Creating instance of a custom layout programmatically

mahaju

Lurker
I am trying to use a custom layout that simulates physics using jbox2d in my app
The custom layout is extended from LinearLayout
The custom layout and sample code on how to use it in xml is given here: https://androidexample365.com/android-layout-that-simulates-physics-using-jbox2d/
The source code for this custom layout is given here: https://github.com/Jawnnypoo/PhysicsLayout

Creating a LinearLayout programmatically involves calling something like

myLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

But even though this custom layout is extended from LinerLayout, it has declared it's version of LayoutParams as private (inside PhysicsLinerlayout.java), so I cannot call the setLayoutParams() function for this custom layout. How can I create an instance of this custom layout programmatically in this case?
 
Back
Top Bottom