Viewpager strange behavior - android-studio

I have three fragment (let's call them Left, Middle and Right for the example)
LeftFragment's onPause() is called only when I go to the RightFragment (and not MiddleFragment). And onResume() is called when I go back to MiddleFragment.
(And vice-versa)
Is it the normal behavior ?

Yes, if you on the middle fragment, Android OS will keep Left and Right fragment ready for you to swipe.
If you are on fisrt fragment, then second fragment will be loaded and if on last then second last fragment will be loaded.

Related

LWUIT + Nokia SDK 2.0 Form turning black, when swiped on screen

I'm having a strange problem with the Form of LWUIT. I am making a simple game, which you can control with the touchscreen. I just want to use simple touch events, no swipes. However, when a swipe event happens, the screen turns fully black. After some normal touch events, the picture comes back, but this is really annoying. Which property of the Form do I have to set, that this doesn't happen?
The problem does also occur on the phone itself, not only on the emulator.
Solution:
I had to override the public void pointerDragged(int x, int y) method inside my form (empty body).

ViewPager containing SurfaceView dows not show other fragments while swiping away from SurfaceView

My setup is the following. I have an Activity with 3 Fragments in a ViewPager. The first and the last Fragment are inflated via xml whereas the center Fragment is a Class derived directly from SurfaceView. This Class has its own rendering thread.
The Project uses ActionBarSherlock 4.0.2 and also the Support Library V4+.
Problem:
When the SurfaceView is shown and I swipe to one of the other Fragments these Fragments are not rendered during the transition. IOW instead of scrolling in the other Fragments the SurcaceView leaves behind previous rendered artefacts (smear).
Once the transition is completed the target Fragment is shown though.
Swiping from one of the outer Fragments to the SurfaceView in the center works as expected.
Possibly related problem:
When using the tabs in the ActionBar to perform the transition instead of swiping the target Fragments are not rendered at all. Although nothing is rendered the controls are active. Eg pressing the (invisible) buttons causes the assigned actions. This causes a refresh making the view visible.
instead of posting the source code I put it all on GitHub
I have tried a lot to find the root cause of the behaviour but to no avail.
Using another non SurfaceView Fragment in the middle works fine.
Wrapping the SurfaceView in a LinearLayout View did not make a
difference.
Switching off the Threadand all custom drawing inside the SurfaceView
had no effect.
Any ideas, suggestions and ideas are welcome.

Ensure a component takes up all available space within a SplitPane

I've got a (horizontal) split pane, with a tabbed pane as the left component. I want to ensure that the content of each tab takes up all available space when the divider of the split pane is resized, but I'm a bit confused as to what I should be binding to what. Any tips?
Thanks,
Joseph.
did you try anything?
Because you described default behavior for most cases. Put any layout manager other from Pane and Group inside SplitPane and they will try to take all available space for them.

How to make full screen in Android 4.0

Android 4.0 phones only have virtual buttons, which actually go invisible when playing youtube/video at fullscreen (the video portion takes over where the buttons are).
I want to do this, but haven't found a way.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
or
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
do not cover the virtual buttons.
Here is an example that shows the type of full screen I'm talking about:
http://www.youtube.com/watch?v=Lw_O1JpmPns
Okay, I added this SYSTEM_UI_FLAG_HIDE_NAVIGATION flag to my video activity and that hid the virtual buttons.
WebView view = new WebView(this);
view.setSystemUiVisibility(WebView.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Another choice is to use the SYSTEM_UI_FLAG_LOW_PROFILE flag. This doesn't hide the buttons though. Instead it makes the buttons go to "Low Profile" mode (basically turns them into little dots)
This works on my device but not in the emulator. Add this tho your activity in AndroidManifest.xml:
<activity ...
android:theme="#android:style/Theme.DeviceDefault.NoActionBar.Fullscreen" >
Inside the onCreate() of your Activity, add this:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Worked well for me (but is not Honeycomb-compatible).
To make the buttons completely invisible, you should do
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE);
The buttons would not use any space on the screen, unless you swipe up from the bottom of the screen. Notice that you need to target at SDK version 19 for this to work.

ScrollView as subview does not respect frame boundaries

I have a UIScrollView (managed by a view controller) which I am using both full screen and as a subview. The full screen version works fine - the subview does not.
The subview is positioned so that it takes up about the bottom half of the screen, with a small - 20 pixels or so - margin at the bottom.
Initially it displays in the correct position but overwrites the bottom margin - even though the scrollview's frame is set to leave the margin.
When I scroll the view up by dragging it, the whole view moves upwards and obscures the top of the window. The frame stops moving when it hits the navigation bar at the top and starts scrolling like a normal scrollview. If I scroll it enough it eventually reveals the margin at the bottom of the screen.
I am at a loss to know what to do - I've tried every spring combination I can think of. I'm now looking at subview clipping.
Images below. The first shows the scrollview on initial page load, positioned correctly aside from lower margin overwrite. The scroll view has a white background.
The second image shows it scrolled up toward the top:
The third image shows it scrolled all the way up to the top - note that the lower margin has become visible.
I'm not 100% sure on this one, but worthy the shot: my guess is you're likely not setting the Bounds property correctly on your table.
To solve this issue, the easiest way would be to set myscrollview.clipsToBounds = true.
Something is definitely wrong here. I think what happens is that you are adding the same instance of scrollview as a subview on itself. So basically what you are left with, is one instance alone. Anything you add to the "subview", is basically added on the superview, since it is the same object.
For example, this is what I think you are doing in the view controller:
//...
private UIScrollView myScrollView;
public override void ViewDidLoad()
{
this.myScrollView = new UIScrollView();
this.View = this.myScrollView;
this.View.AddSubview(this.mySrcollView); // same instance
this.myScrollView.AddSubview(aUIButton); // "aUIButton" will be added in View also, since it is the same object
}
If this is the case, it is wrong. I suggest not changing the controller's view at all. If you want to have a controller that has a fullscreen UIScrollView, just create it and add it as a subview, making sure the AutoSizesSubviews property to true.
That's my understanding at least.

Resources