totally_insane
Lurker
Hey,
How can i set the layout_margin property of an ImageButton in code?
Heres what i've got:
Well, theres an error - classcastException - sure..
The setLayoutParams wants an "LayoutParams" and im giving a "MarginLayoutParams".
Well that was finally what I tried.
Any ideas how i can make that working?
How can i set the layout_margin property of an ImageButton in code?
Heres what i've got:
Code:
ImageButton ib = (ImageButton) findViewById(R.id.btn_learn);
MarginLayoutParams mlp = new MarginLayoutParams(ib.getLayoutParams());
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
mlp.setMargins(0, 20, 0, 0);
else
mlp.setMargins(0, 100, 0, 0);
ib.setLayoutParams(mlp); // ERROR HERE
Well, theres an error - classcastException - sure..
The setLayoutParams wants an "LayoutParams" and im giving a "MarginLayoutParams".
Well that was finally what I tried.
Any ideas how i can make that working?