Jedes Mal, wenn ich die Höhe eines Linearlayout versuchen Einstellung, habe ich immer diese Ausnahme:Höhe einstellen linearen Layout programmatisch
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
Hier ist mein Code:
LinearLayout.LayoutParams hide = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
LinearLayout.LayoutParams show = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
driverMainOptions.setLayoutParams(hide);
mapDirections.setLayoutParams(show);
Gibt es eine spezielle Import-Anweisung Ich muss das richtig ausführen?
Es scheint, dass ein Ihr Layout ist ein 'RelativeLayout' –
Die Art der' LayoutParams' ein 'View' hat, hängt von seiner Mutter 'View', nicht was es selbst ist. Ihr 'LinearLayout' scheint in einem' RelativeLayout' zu liegen, ebenso wie 'RelativeLayout.LayoutParams', nicht' LinearLayout.LayoutParams'. –
@JuanCruzSoler Die Layouts, die ich modifiziere, sind Linear. Das relative Layout ist so ziemlich das übergeordnete Element aller Objekte, aber die Objekte, die ich bearbeiten möchte, sind Linear – purewatashi21