I have designed a menu that consists of a few buttons in several different LinearLayouts all placed over an animated GLSurfaceView within a FrameLayout. When the user clicks a button in the interface, I set the current layout's visibility to GONE before making the next layout VISIBLE When the user selects a level, then game play starts and all layouts are GONE (apart from a control bar on the right of the screen, but that is not contained inside the FrameLayout)
On most phones the menu works like a charm, but I did a quick test on an Xperia Ray only to find that I couldn't go anywhere because the buttons wouldn't click. I have Log.d tags set up in most of my onClick Listeners, and in this case they aren't showing in the Logcat so it doesn't seem like the Listeners are firing at all. I also noticed that the GLSurfaceView wasn't returning anything from it's own TouchEventListener. Even though the functions triggered by tapping the GLSurfaceView are disabled while on the top menu, I normally still get a message in the Logcat.
I thought it could be something to do with the way I have used the FrameLayout. The documentation says it should only have one child, but another article I read on android developers demonstrated captioning images by displaying text over ImageViews inside a FrameLayout.
On a final note, I'll also say that I've tested in the emulators and I found that both android v2.3 and android v4 display the same behaviour as the ray. Currently those are the only ones I am sure of, aside from android v2.2 which runs my app perfectly. I am hesitant to trust the results of testing on the emulators.
I am personally stumped seeing as there is no error message to go on, but can anybody suggest a solution?
I found the solution.
Turns out that I had a stray ScrollView hanging around in my layout that was both above my root layout in z-order and visible by default. Instead of toggling the visibility of this view, I was doing so for it's child layout. Oops.
On most devices I have tested on, the stray ScrollView has not effected the functionality of my app, probably because the empty layout was allowing buttons behind it to be clicked. However it turns out that some devices, such as the Xperia Ray, are a little more strict on whether clicks can be passed down through layouts (possibly a performance decision).
The ScrollView was a required part of the layout so I couldn't just remove it. Instead I gave the the android:visibilty attribute to the ScrollView so that it would be GONE until it is needed by the interface and it won't block the user from clicking buttons.
Related
I am new to writing Android apps, I have been using the internet and Android Studio to create an app for my club as a bit of fun and learn along the way. I have been watching videos, using tutorials and walkthroughs and I am getting to learn the basics.
However, I have got stuck. I used a drawer template from Android Studio and added the activities I needed and buttons on the main screen to the activities and they all worked fine, no overlapping. When I tried to link the drawer icons to the activities, rather than use the buttons on the main screen, they work, but the app (visually) puts the next activities content on top of the one before.
I cant find anything on the internet except something called backstacking, but that is described when the back arrow is used, my problem is to do with selecting an activity from the drawer menu. I have attached a picture to show what I mean. It gets worse the more menu items that are selected.
If anyone could help, it would be great!
If you are using XML root layout as a constraint layout maybe your constraints are missing. If you are using constraint layout set both top/bottom and left/right constraint.
If your constraints only top for example it is look good on desing but in device that dont know where to positioning left or right and automatically positioning 0 point to top.
When you click one any one menu item put the visibility of other images as gone like
visibility(View.GONE);
and the one selected to be visible
In my app, based on user interactions, I have images appear, disappear, reappear ect. Based on one interaction, I want a invisible image to NOT reappear again, even if the user does what triggered it's visibility before. I have been using visible and invisible, but when I use the gone method it distorts many things in my layout. (Relative Layout). Is there a better way to go about this? I tried a few other methods suggested by eclipse. Thanks.
My question is, is there a way to get a certain view element to ignore the windowSoftInput setting, or to set a specific setting for one view element? (Any other solutions to my problem are also welcome)
Below are more details about my problem.
I have an Android activity with a background image set to the main FrameLayout. This layout contains a few other layouts, among others a brand logo on one side, and a scrollview with edittext boxes on the other side.
Using the windowSoftInput="adjustResize" works pretty well, but it distorts the background image. Using windowSoftInput="adjustPan" however pans the brand logo out of the screen and messes with the scrollview, and the keyboard blocks the edittext boxes.
So far, looking around the web and the docs I can't find a solution, or if this is even possible. Android layouts always seem to confuse me though..
So I have an application running on Android 2.2 (on a HTC desire). When the user presses the menu key, my menus silkily slide in from top and bottom. This works just great. Or so I thought. It turns out that even when the ImageButtons are off screen and invisible, the hitboxes of the places where they were before I moved them out of sight activate the buttons.
I have tried:
_top_slide_out_menu.forceLayout();
_top_slide_out_menu.recomputeViewAttributes(_measure);
_top_slide_out_menu.computeScroll();
No difference. At a guess it may be because I am moving the parent container object using the animation rather than the buttons themselves. I can only hypothesise that there is a bug that does not update the child hitboxes.
This bug seems to also affect subsequent animations I apply to the button. I have a animation I run on a button that I have previously moved using a different animation. This second animation shrinks then grows the button to give the impression of a click. Only half of the button is redrawn, as that is the half contained within the area of the origional button location.
So the question is, has anyone run into this? Is there anything to try other than moving all the buttons individually (which would get rather tiresome)?
I'd appreciate any ideas at this point!
Thanks
Android animations only shifts the pixels of the UI controls when you add animations to them. To actually update the layout after the animation, you should implement an animation listener and manually update the layout other wise the old layout will still remain with the only the pixels shifted.
I found a nice feature in Dolphin browser that brings another window from the side on a side-swipe. It's like the window is connected and revealed by swipe. See image below. Anyone knows how it is done?
I might be wrong but my guess would be they use a SlidingDrawer set to a lanscape orientation in a portrait layout (so it comes from the side rather than the top/bottom).
EDIT: Ok, I see now - I was rushing to go to work and didn't pick up on the fact the left hand side is displaced.
I suppose you could use two opposing SlidingDrawer views and force one to be initially open and the other initially closed. If their 'handle' views were identical and overlapped, then the effect would be similar to what you are seeing.
I'm not sure if the 'purists' would approve as the SlidingDrawer is meant to be used in an overlay fashion, i.e., it is meant to cover an existing view rather than to appear to move another out of the way. Then again, I've been coding for many years and often go on the principle that if it works why not use it?
Alternatively, there is some example code on smooth horizontal view scrolling in the answer to this question if it is of use. Horizontal Scrolling with fling gesture - ebook reader