I am trying to programmatically resize a custom view in android. The custom view contains a Button and an EditText in a LinearLayout. I want to make several instances of this custom view and alter the width of each one slightly narrower than the last so that they overlap each other. At what point can I do this and how?
If I override the custom view's onWindowFocusChanged() to set the width using this.setLayoutParams( newWidth, LayoutParams.FILL_PARENT); it crashes later on with a ClassCastException in the LinearLayout. Like this... @Override public void onWindowFocusChanged( boolean changed ) { super.onWindowFocusChanged( changed ); // reset the width int fullWidth = this.getWidth(); if( fullWidth > 0 ) { int width = fullWidth - (20 * (viewNumber)); this.setLayoutParams(new LinearLayout.LayoutParams( width, LayoutParams.FILL_PARENT)); } } So, obviously, this is not the way to do it. How then? Thanks -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en