I'm working on some test code, just playing around with some image processing methods, and this display may well end up being used in an app for image processing. The layout uses a RelativeLayout, with the relevant portion shown below:
--------------------------- CUT HERE --------------------------- <ImageView android:id="@+id/originalView" android:scaleType="fitXY" android:adjustViewBounds="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/filteredView" android:scaleType="fitXY" android:adjustViewBounds="true" android:layout_alignParentTop="true" android:layout_toRightOf="@id/originalView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> and after a SeekBar and its two TextViews, which work fine, a ListView, which is also fine: <ListView android:id="@+id/filterList" android:textSize="22sp" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_height="fill_parent" android:layout_width="300dp"> </ListView> --------------------------- CUT HERE --------------------------- Note that in the layout, the second (filtered) ImageView is configured to align to the right of the original, and on the top of the display. I want to make this right, from the beginning, in case I do use this layout for image processing (or at least, the final version of it---it's not finished yet). To do that, I plan on scaling the two ImageViews (which, in turn, will scale the images inside, as I'm using fitXY for the scaling method for the ImageViews). I'm trying to scale these to equal fractions of the remaining screen width (orientation set to landscape) after the ListView on the far right. If I hard-code the ImaveView widths for my tablet, it works fine. If I try to resize these from Java, the two ImageViews, which are supposed to be side by side, end up with the filtered (result) ImageView ON TOP of the one for the original image. This is definitely not what I'm trying to do. This is the code to resize the ImageViews: // original is a reduced-size copy of the real original bitmap int oiw = (float) original.getWidth(); int oih = (float) original.getHeight(); // Scale the two ImageViews relative to the display size, maintaining // the correct aspect ratio. The ListView on the right of these is // 300dp wide, and I leave room for padding int iw = (int) ((dw - 340) / 2); int ih = (int) (iw * (float)(oih/oiw)); // and these are the lines I suspect are causing the error // origView.setLayoutParams(new RelativeLayout.LayoutParams(iw, ih)); filtView.setLayoutParams(new RelativeLayout.LayoutParams(iw, ih)); Again, without the above re-sizing from Java (and the ImageView sizes hard-coded in XML), the layout works fine. I'm assuming that the problem is something I'm doing, and not a bug in RelativeLayout itself (obviously...). But whatever the problem is, I can't see it, and have yet to find any reference that gives me any kind of a hint as to what I'm doing wrong. Can anyone here see what's wrong? If so, how would I fix it? Oh, as a side note: when I tried the above code with an intermediate step (calculate the aspect ratio BEFORE using it in the calculation for re-sizing, as follows (with the original image width, oiw, and height, either ints or floats...casting every calculation to float), I get the same result either way: float aspect = (float) oih/oiw; (yes, technically, that's 1/aspect ratio ... it's for the math that follows to get the new height from the new width). No matter what, it ends up being 0.0 (should be 0.75 for the test image in use). Put that inline as above, and it works. Apparently, Android doesn't know that (float) 2/3 is 0.6666666 (ad infinitum), NOT 0.0.... The same happens if the two original dimensions are both floats. Btw, the layout should look something like this: Top of displayt: ImageView ImageView ListView Below that: Filter Level (list continued) Below that: Seekbar - Value (list continued) Below that: Red (list continued) Below that: Seekbar - Value (list continued) Below that: Green (list continued) Below that: Seekbar - Value (list continued) Below that: Blue (list continued) Below that: Seekbar - Value (list continued) Thanks, --jim -- THE SCORE: ME: 2 CANCER: 0 73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 > spooky1...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W Do not look into waveguide with remaining eye! Android Apps Listing at http://www.jstrack.org/barcodes.html -- 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