Monday, July 1, 2013

[android-developers] setLayoutParams stops working

I'm using setLayoutParams on some images in a HorizontalScrollView to change their size as they scroll past.   This seems to work fine, until I hit one of the boundaries, then all the imageViews stop responding to setLayoutParams.  They are locked in at their last size.  Monitoring my code, I can absolutely see that there are no errors being thrown and that setLayoutParams is definitely being called with changing values, just like before they got locked in.   The UI, which continuing to scroll, is just refusing to update my layout params on this ImageView now.

Very frustrating..  Any ideas what's going on here?


int iWidth = (int) (scale * 108 * getResources().getDisplayMetrics().density);

int iHeight = (int) (scale * 56 * getResources().getDisplayMetrics().density);

if(r == R.id.imageView5){

//Log.v("LOCATION", String.valueOf(imageViewCenter) );

//Log.v("OFFSET", String.valueOf(offset));

//Log.v("RATIO", String.valueOf(ratio));

//Log.v("SCALE", String.valueOf(scale));

Log.v("DIMS", String.valueOf(iWidth) + ":" + String.valueOf(iHeight) );

}

LinearLayout.LayoutParams layoutParams = (android.widget.LinearLayout.LayoutParams) iv.getLayoutParams();

layoutParams.height = iHeight;

layoutParams.width = iWidth;

iv.setLayoutParams(layoutParams);

--
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment