I want to know whether my activity is in upper view or bottom view in the multi-window mode.
The reason for this is I'm using a custom MediaController in a player activity which gets behind the NavigationBar.
Earlier I handled this by adding a bottom margin of the NavigationBarheight to the MediaController but I can't use it in multi-window mode.
When the activity is in upper view of the multi-window mode, I need to remove the bottom margin and when it is in bottom view, I have to provide the bottom margin.
I've tried applying android:fitsInSystemWindows=true attribute to the activity layout and media controller layout, but it didn't help.
Can anyone help me with this?
You can use View:getWindowVisibleFrame method and check rect.top.
Related
I am changing the window attribute with user gesture like swipe.
getWindow().getAttributes().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
My activity is not extending to full screen. Where as if the same line is used in onCreate method, view is rendering in full screen underneath the cutout. But if I try to do the same action with some user touch event/gesture, it doesn't work.
My question is: with the new cutout mode set to window, how can we apply those window attributes to our view to make our view appear in full screen?
Thanks in advance.
I wonder and not getting how facebook manages to fit the layout on all screen sizes by removing the padding or margins as shown below in landscape mode and open keyboard mode.
If anyone has implemented the same or getting the logic behind it please let me know.
If you place the elements inside a ScrollView, they will automatically move up when the keyboard is open. You must also have android:windowSoftInputMode="adjustResize" in your AndroidManifest.xml file for the appropriate Activity.
I'd been trying to maintain consistency in layout whether keyboard is open or not. These issue is generated in FULLSCREEN Mode (hiding top notification bar) only. It works like a charm without Fullscreen.
Tried:
Added android:softWindowMode="adjustResize" and android:softWindowMode="adjustPan"inside <activity> of Manifest File.
Added android:isScrollableContainer="false" inside by top layout with blue background having first, next,prev,last symbol.
Desired Layout:
Top Layout Blue Background should never get hide whether keyboard is open or not.
These issue get resolved with ActionBar but it requires a lot of turn work which I don't intent to.
.
Is there any way other than ActionBar which resolve my issue?
Try to create a fixed header layout for the blue back ground layout, and below this blue layout create a layout for other fields inside the ScrollView ...so that when keyboard appeared it will not hide the header blue layout...
I have a TabActivity which has the tabs across the bottom of the screen. My first tab hosts an activity which consists of a fixed header layout at the top of the screen, and a ScrollView beneath it which contains several EditText controls. The ScrollView scrolls it's content fine between the header bar and the bottom tabs, the problem occurs when an EditText is tapped and the soft keyboard appears. I understand to control the behaviour of the views when the keyboard appears I need to use the windowSoftInputMode attribute in the manifest XML file. However I've tried both the following settings :
adjustResize - Gives the correct functionality for the ScrollView and the header layout remains fixed at the top of the screen. However the tab bar controls are pushed up on top of the keyboard.
adjustPan - The tab bar controls remain at the bottom of the screen beneath the keyboard (which is what I want) but the other views are pushed up by the keyboard meaning the header layout gets pushed up off the screen.
It seems I need characteristics of both settings, but they can't be used together. I've heard of the setting adjustNothing but if I try this my project fails to build as it doesn't recognise this setting. I guess I need my tab host activity to have adjustPan but my content activity to have adjustResize but it seems you can't combine the two as it's the tab host activity that takes precedence.
Any help greatly appreciated.
In the absence of any direct solution for this, I have resorted to a kind of hack. I have set my TabHost activity to adjustResize and then written code to hide/unhide the tab bar controls (TabWidget) when the soft keyboard appears/disappears. I managed to get a pretty good result in the end, using the technique here : Adjust layout when soft keyboard is on to detect the keyboard appearing/disappearing.
I want my Android application to behave like below.
1) Portrait mode: With title bar
2) Landscape mode: Without title bar (because of height limitation)
I know I can realize 1) using requestWindowFeature(Window.FEATURE_NO_TITLE), but
how can I dynamically change from 1) to 2) when I rotate my phone?
When the phone is rotated, your activity is shut down and recreated. Inside onCreate, you can grab an instance of Display (using getWindowManager().getDefaultDisplay()) and query its width, height, and/or rotation to decide if you want a title feature, all before setting the content view.
This answer suggests you can't change the feature during the lifecycle of the activity (as happens when the orientation changes), so they recommend implementing your own title (jump to the "::Edit::" part):
Hiding Title in a Fullscreen mode?
::Edit::
Well if you are trying to dynamically show and hide it during the lifetime of the activity I am not sure if you can do that with the official Window Title due to the note that has been mentioned about window features needing to be set before setContentView() is called.
One thing that you could do is implement your own title bar and dynamically show and hide that... I put together this example that should set you o nthe right track
Since when you change orientation, your app goes through a set of lifecycle changes, you have an opportunity in onCreate to show or hide your title.
http://stuffthathappens.com/blog/2008/11/26/android-lifecycle-triggers-part-2/
Or you specify a different layout altogether for landscape mode:
http://developer.android.com/resources/tutorials/hello-world.html
Landscape layout
When you want a different design for landscape, put your layout XML file inside /res/layout-land. Android will automatically look here when the layout changes. Without this special landscape layout defined, Android will stretch the default layout.