File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes framelayout issue (again) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "framelayout issue (again)" Watch "framelayout issue (again)" New topic

framelayout issue (again)

Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124
I asked about this earlier. Anyway,

The top level layout in my activity is a framelayout. I have completed, debugged and tested this app and it works exactly like it should
in all respects on my g1 and on various emulators. But on 3.7-inch displays running 2.1+, some imageviews packed in a linearlayout
are not visible. I know that they are there because you can touch and drag them with effect in the app. So I assume somehow
they have gotten under one of the other views.

Framelayout stacks everything that is added to it, one on top of the other--the only way you will see more than one child of a frame layout is if they smaller than the screen and are placed apart from eachother.

Oddly, sometimes the imageviews ARE visible--it is random. Anyway, I've been trying to combat this with framelayout.bringChildToFront(View v) on the linearlayout without success.

I wonder if anyone has any insight into how the behavior could be random like that, and how I should code these imageviews
to keep this from happening.

SCJP 88% | SCWCD 84%
Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124
Since I know you are all riveted by this topic, I will update the situation: bringChildToFrong(), in several different places, hasn't
solved the problem--neither calling the linearlayout to front nor each individual imageview in the linearlayout has stopped this
odd random behavior.

It HAS dawned on me though that these new phones might be running 2.2 and not 2.1--so I downloaded it and indeed I get the
screwy behavior on the emulator--where I can do something about. So it shouldn't be long before I figure it out.
Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124
And now I've discovered that actually putting ImageViews in the linearlayout in the main xml doesn't do it either--the images
still aren't visible. But when I set the background color to something that would be visible over the SurfaceView background,
there were indeed squares of the appropriate color visible. I then set the imageviews programmatically again and added background color and saw them again. From this I take it that the imageviews (and linearlayout they were in) ARE above anything that would otherwise obscure them and are visible, but the *drawables* in the imageviews aren't being displayed for some reason.

Now, to find that reason.
Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124
With the 2.2 emulator running, I determined that despite having set the bounds of the drawables in the Imageviews in one
class, they were back at zeroes for the doDraw() in the SurfaceView subclass. That's odd, isn't it?

After some more screwing around I found the only way I could get these drawables to display in my SurfaceView was to
change the file names and do without the ImageViews. This went just for this one set of drawables--other imageviews
(displaying non 'pegs' -- you'd have to know my app) worked just fine.

As it happens, I have reason to believe somebody (or somebodies) got to my laptop and messed with it. Maybe this is some
kind of malicious code or something. Probably not, but anyway, I had to recode all the support for my drag and drop stuff
because I could no longer utilize ImageView's onTouch functionality (or the handling code I'd written into my subclass).

I don't know really what the issue was, but it's all good now. File this one in the folder marked 'X'.
I agree. Here's the link:
subject: framelayout issue (again)
jQuery in Action, 3rd edition