[android-developers] RelativeLayout problems

2012-05-22 Thread Jim Graham
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.666 (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 

Re: [android-developers] RelativeLayout problems

2010-12-27 Thread John Lussmyer
I fixed the id problem that was pointed out by the previous reply.  It made
no difference.

On Sun, Dec 26, 2010 at 11:44 PM, Kostya Vasilyev kmans...@gmail.comwrote:

 John,

 Two suggestions:

 1 - When your app suspends like this, it means it's crashing, but hasn't
 quite crashed all the way yet, which is why there is no logcat output at
 that point.

 Click 'resume execution' in Eclipse, and again if necessary. You only get
 logcat output (and the close dialog on the device) once the exception has
 propagated to the top-level exception handler.


I tried clicking on resume. Twice.  The app exited, the debugger
disconnected from the Emulator, and still no logcat output.


 2 - Logcat window in Eclipse is very nice (filtering, color highlighting),
 but just too small.


Not on my screen.  I re-arranged the tabs in Eclipse, and have a 24
1920x1200 monitor.

-- 
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

Re: [android-developers] RelativeLayout problems

2010-12-27 Thread TreKing
On Mon, Dec 27, 2010 at 9:00 AM, John Lussmyer johnlussm...@gmail.comwrote:

 I tried clicking on resume. Twice.  The app exited, the debugger
 disconnected from the Emulator, and still no logcat output.


If you don't get any LogCat output, go to the devices view and re-select
your device. Sometimes it gets deselected.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
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

[android-developers] RelativeLayout problems

2010-12-26 Thread John Lussmyer
I'm attempting a not-that-complex layout using RelativeLayout, and getting a
weird problem.

When I set things up in a way that seems correct, I get:

Thread [3 main] (Suspended (exception IllegalStateException))
RelativeLayout$DependencyGraph.getSortedViews(View[], int...) line:
1260
RelativeLayout.sortChildren() line: 281
RelativeLayout.onMeasure(int, int) line: 299
RelativeLayout(View).measure(int, int) line: 7964


The full layout is at the bottom of this msg.
If I delete just one line,
 android:layout_toRightOf=@id/Spin
from the 3rd widget (ImageButton), the layout then sort-of works. (well, at
least it doesn't crash)

The 1st NumberPicker (SpinMeasure) is at the top of the screen - but is the
full screen width.
The BtnRun is at the top right corner, overlapping SpinMeasure.  BtnMute and
CenterLayout appear correct.
SpinRate isn't visible.  It's either not there, or is under SpinMeasure.

Any suggestions on what I'm doing wrong?

- landscape layout -

?xml version=1.0 encoding=utf-8?
RelativeLayout
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=fill_parent
android:id=@+id/WholeScreen

com.casadelgato.widgets.NumberPicker
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentLeft=true
android:layout_alignParentTop=true
plusminus_width=50
vertical=false
minValue=0
defaultValue=4
maxValue=16
android:id=@+id/SpinMeasure /
com.casadelgato.widgets.NumberPicker
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentTop=true
android:layout_toRightOf=@id/SpinMeasure
android:layout_toLeftOf=@+id/BtnRun
minValue=20
defaultValue=60
maxValue=240
repeatAcceleration = 10
vertical=false
android:id=@id/SpinRate/
ImageButton
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentRight=true
android:layout_alignParentTop=true
android:layout_toRightOf=@id/SpinRate
android:src=@drawable/ic_menu_play_clip
android:id=@id/BtnRun /
RelativeLayout
android:layout_width=fill_parent
android:layout_height=fill_parent
android:layout_toLeftOf=@+id/BtnMute
android:layout_below=@id/SpinRate
android:layout_alignParentBottom=true
android:layout_alignParentLeft=true
android:id=@+id/CenterLayout /
ImageButton
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentBottom=true
android:layout_alignParentRight=true
android:layout_alignLeft=@id/BtnRun
android:src=@drawable/ic_jog_dial_sound_off
android:id=@id/BtnMute /
/RelativeLayout

-- 
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

Re: [android-developers] RelativeLayout problems

2010-12-26 Thread Adarsh Pandey
I think you trying to use id which is not created :

android:id=@id/SpinRate

try this

android:id=@+id/SpinRate

On Mon, Dec 27, 2010 at 9:14 AM, John Lussmyer johnlussm...@gmail.comwrote:

 I'm attempting a not-that-complex layout using RelativeLayout, and getting
 a weird problem.

 When I set things up in a way that seems correct, I get:

 Thread [3 main] (Suspended (exception IllegalStateException))
 RelativeLayout$DependencyGraph.getSortedViews(View[], int...) line:
 1260
 RelativeLayout.sortChildren() line: 281
 RelativeLayout.onMeasure(int, int) line: 299
 RelativeLayout(View).measure(int, int) line: 7964
 

 The full layout is at the bottom of this msg.
 If I delete just one line,
  android:layout_toRightOf=@id/Spin
 from the 3rd widget (ImageButton), the layout then sort-of works. (well, at
 least it doesn't crash)

 The 1st NumberPicker (SpinMeasure) is at the top of the screen - but is the
 full screen width.
 The BtnRun is at the top right corner, overlapping SpinMeasure.  BtnMute
 and CenterLayout appear correct.
 SpinRate isn't visible.  It's either not there, or is under SpinMeasure.

 Any suggestions on what I'm doing wrong?

 - landscape layout -

 ?xml version=1.0 encoding=utf-8?
 RelativeLayout
 xmlns:android=http://schemas.android.com/apk/res/android;
 android:layout_width=fill_parent
 android:layout_height=fill_parent
 android:id=@+id/WholeScreen
 
 com.casadelgato.widgets.NumberPicker
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_alignParentLeft=true
 android:layout_alignParentTop=true
 plusminus_width=50
 vertical=false
 minValue=0
 defaultValue=4
 maxValue=16
 android:id=@+id/SpinMeasure /
 com.casadelgato.widgets.NumberPicker
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_alignParentTop=true
 android:layout_toRightOf=@id/SpinMeasure
 android:layout_toLeftOf=@+id/BtnRun
 minValue=20
 defaultValue=60
 maxValue=240
 repeatAcceleration = 10
 vertical=false
 android:id=@id/SpinRate/
 ImageButton
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_alignParentRight=true
 android:layout_alignParentTop=true
 android:layout_toRightOf=@id/SpinRate
 android:src=@drawable/ic_menu_play_clip
 android:id=@id/BtnRun /
 RelativeLayout
 android:layout_width=fill_parent
 android:layout_height=fill_parent
 android:layout_toLeftOf=@+id/BtnMute
 android:layout_below=@id/SpinRate
 android:layout_alignParentBottom=true
 android:layout_alignParentLeft=true
 android:id=@+id/CenterLayout /
 ImageButton
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_alignParentBottom=true
 android:layout_alignParentRight=true
 android:layout_alignLeft=@id/BtnRun
 android:src=@drawable/ic_jog_dial_sound_off
 android:id=@id/BtnMute /
 /RelativeLayout

 --
 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.comandroid-developers%2bunsubscr...@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 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

Re: [android-developers] RelativeLayout problems

2010-12-26 Thread Kostya Vasilyev

John,

Two suggestions:

1 - When your app suspends like this, it means it's crashing, but 
hasn't quite crashed all the way yet, which is why there is no logcat 
output at that point.


Click 'resume execution' in Eclipse, and again if necessary. You only 
get logcat output (and the close dialog on the device) once the 
exception has propagated to the top-level exception handler.


2 - Logcat window in Eclipse is very nice (filtering, color 
highlighting), but just too small.


Run adb logcat in a command line window, make the window large, and 
set a nice ample scrollback value in properties - with this, you'll much 
more.


-- Kostya

27.12.2010 6:44, John Lussmyer пишет:
I'm attempting a not-that-complex layout using RelativeLayout, and 
getting a weird problem.


When I set things up in a way that seems correct, I get:

Thread [3 main] (Suspended (exception IllegalStateException))
RelativeLayout$DependencyGraph.getSortedViews(View[], int...) line: 1260
RelativeLayout.sortChildren() line: 281
RelativeLayout.onMeasure(int, int) line: 299
RelativeLayout(View).measure(int, int) line: 7964


The full layout is at the bottom of this msg.
If I delete just one line,
android:layout_toRightOf=@id/Spin
from the 3rd widget (ImageButton), the layout then sort-of works. 
(well, at least it doesn't crash)


The 1st NumberPicker (SpinMeasure) is at the top of the screen - but 
is the full screen width.
The BtnRun is at the top right corner, overlapping SpinMeasure. 
BtnMute and CenterLayout appear correct.

SpinRate isn't visible. It's either not there, or is under SpinMeasure.

Any suggestions on what I'm doing wrong?

- landscape layout -

?xml version=1.0 encoding=utf-8?
RelativeLayout
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=fill_parent
android:id=@+id/WholeScreen

com.casadelgato.widgets.NumberPicker
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentLeft=true
android:layout_alignParentTop=true
plusminus_width=50
vertical=false
minValue=0
defaultValue=4
maxValue=16
android:id=@+id/SpinMeasure /
com.casadelgato.widgets.NumberPicker
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentTop=true
android:layout_toRightOf=@id/SpinMeasure
android:layout_toLeftOf=@+id/BtnRun
minValue=20
defaultValue=60
maxValue=240
repeatAcceleration = 10
vertical=false
android:id=@id/SpinRate/
ImageButton
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentRight=true
android:layout_alignParentTop=true
android:layout_toRightOf=@id/SpinRate
android:src=@drawable/ic_menu_play_clip
android:id=@id/BtnRun /
RelativeLayout
android:layout_width=fill_parent
android:layout_height=fill_parent
android:layout_toLeftOf=@+id/BtnMute
android:layout_below=@id/SpinRate
android:layout_alignParentBottom=true
android:layout_alignParentLeft=true
android:id=@+id/CenterLayout /
ImageButton
android:layout_width=wrap_content
android:layout_height=wrap_content
android:layout_alignParentBottom=true
android:layout_alignParentRight=true
android:layout_alignLeft=@id/BtnRun
android:src=@drawable/ic_jog_dial_sound_off
android:id=@id/BtnMute /
/RelativeLayout
--
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 



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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