Android layouts: fit View under Action Bar - android

I'm using the action bar as a translucent overlay (like the Google Earth app), using:
<item name="android:windowActionBarOverlay">true</item>
All my Views of full-screen height now extend beneath the action bar, but I only want one of them to do that. So my question is, is there a way to automatically fit Views so that they do not extend underneath the action bar overlay? I'd rather not have to use a custom dp setting.

There is no way to fit the views automatically since action bar is in overlay mode. You need to set action bar height as marginTop for the view. You can refer the android documentation here

Related

Add/ remove ActionBar shadow from Fragment

i have an activity where i am switching between fragments.
some fragments i want to have the action bar show in full, others i want it to be transparent.
i used the trick found in the answer to this question, where i essentially have a theme that has:
<item name="windowActionBarOverlay">true</item>
and in my layouts where i want a static/ full action bar i'll add:
`layout_marginTop:"?android:attr/actionBarSize"`
in the fragments where i want a transparent action bar, i'll do:
getActivity().getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(0, 0, 0, 0)));
the problem: in the latter case, the action bar shadow still shows. i can disable it if i add:
<item name="android:windowContentOverlay">#null</item>
but now what about when i want the action bar to show in full/ non-transparent? i want the shadow to show with it as well. so is there a way to trigger that shadow on and off?
alternatively, i could just ditch the whole styling deal and just do:
getActivity().getSupportActionBar().show(); // or hide
and then in my layout i could manually add the back button that i want from the action bar. the issue in that case is that the action bar slides in and out and looks sloppy. i can't call:
getActivity().getSupportActionBar().setShowHideAnimationEnabled(false);
because it tells me:
ActionBar.setShowHideAnimationEnabled can only be called from within the same library group (groupId=com.android.support)
so how can i add/remove the action bar shadow depending on which fragment is showing? or else, how can i hide the action bar without animation?
thanks!

Put android tabs in center of action bar

I tried Android action bar with tabs. As you see in this picture:
(source: persiangig.com)
My action bar looks good in phones but in tablets it is not right, the tabs stick left. This picture shows what I mean, how can I put the tabs to center in tablets too?
(source: persiangig.com)
The tabs are aligned left because, in Android, the action bar is used for both navigation and Activity- or Fragment-specific actions. You don't have any in this screenshot, but menu actions that are added to the action bar will be aligned to the right.
If you must have your tabs centered for some reason, you'll have to write your own action bar. I would recommend against this, since it's a lot of work to intentionally go against user expectations. Instead, use Android's built-in action bar layout and design your app to accommodate it.

Overlay action bar with a translucent status bar

I'm trying to achieve the effect shown here: http://www.youtube.com/watch?v=6QHkv-bSlds&t=15m48s by Nick and the boys. I can get the action bar to be overlayed, but cannot figure out how to extend this to the status bar. I would also like to know how they managed the transparent black background behind the navigation bar (but this isn't as crucial).
Any help / advice would be greatly appreciated as I currently have no idea how this is done (and am starting to worry it may just be an image rather than an actual implementation).
Edit: i know how to make the bars fully transparent (thats the easy part)! I dont know how to extend the actionbar background to appear behind the now transluscent status bar
I had the same question and found this library: https://github.com/jgilfelt/SystemBarTint
Have a look at line 300 in:
https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java
setupStatusBarView() Adds a view to the window's decor. This allows you to later set a color/drawable to this view.
If using the SystemBarTint library, the following will allow you to force the status bar to a specified color, which you can then match to your action bar's background:
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(Color.parseColor("#DD000000"));
In this case you would set your action bar's background to: #DD000000
As described in the Android 4.4 APIs:
You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.
In your case (where you want the ActionBar), the second option - including the two new properties into your theme - will give you a translucent Navigation and Status bar.
They are using the new Translucent system bars feature (on Android 4.4 and up).
Translucent system bars
You can now make the system bars partially translucent with new
themes, Theme.Holo.NoActionBar.TranslucentDecor and
Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent
system bars, your layout will fill the area behind the system bars, so
you must also enable fitsSystemWindows for the portion of your layout
that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the
parent theme or include the windowTranslucentNavigation and
windowTranslucentStatus style properties in your theme.

Fitting View into Actionbar

I'm working on integrating a custom view into the action bar. Currently I am successfully getting the view to display. However some of the view is appearing off the edge of the action bar boundary.
Is there any way I can set the action bar to adjust it's size to fit the entire contents of the view or is the only solution to make the various components of the view slightly smaller...
many thanks
You could adjust the height of the ActionBar from the action bar theme style, or you define your custom theme which inherits from the parent theme, and add the "height" attribute. (I don't remember how it was called exactly)

Customize system combined bar /navigation bar for Android tablet (bottom)

I would like to override (add more buttons that would take me to several activities/fragments) to the system Navigation Bar on a tablet (according to this android ui-overview it is a "Combined bar" (for tablets)
Is there a way to do this?
I couldn't find a Navigation class in the android.app package, like ActionBar.
If adding buttons to the combined/navigation bar is not possible, I think there are several options, but I'd like to explore this first:
- use the action bar on top instead
- add a bottom bar above the navigation bar (not really fine, since it would be on top of the combined bar), like they are showing here:
Action Bar
Thanks a lot,
Cristian
Is there a way to do this?
No. The only thing you can add to the system bar are Notifications, which are not meant for this sort of navigation.
If adding buttons to the combined/navigation bar is not possible, I think there are several options, but I'd like to explore this first: - use the action bar on top instead - add a bottom bar above the navigation bar (not really fine, since it would be on top of the combined bar), like they are showing here: Action Bar
If you are referring to the section titled "Layout Considerations for Split Action Bars", that is referred to as a "split action bar", and can be enabled on an <activity> via android:uiOptions="splitActionBarWhenNarrow". However, that will only take effect for -small/-normal screens in portrait orientation. Your buttons will automatically be placed in the action bar at the top of the screen in other circumstances.

Categories

Resources