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!
Related
I have created a fly-out (sliding) menu by an example.
In example author uses NoActionBar attribute for activity to hide action bar.
But in my app I want to use actionBar's tabs (tabbed control, tab navigation) for navigation (like in a third picture).
Also in first and second pictures we can see a fly-out menu with desired view (screens from vk android app). Theirs menu hovers above action bar and they use tab control!
Last picture is my app. There menu is under action bar.
So, my question is: How can I make fly-out menu that will hover above action bar? But not with hiding action bar, so I will have possibility to use actionBar's tabs (it is impossible with NoActionBar attribute).
]
UPD: Found nice example here https://github.com/Cheesebaron/SlidingMenuSharp
I recommend you looking into this example, it has all the needed information: https://github.com/chrisbanes/cheesesquare
Your problem is that you inflate your navbar "under" the main activity (I guess, in a fragment).
I want to customize navigation drawer app compact action bar, I want to remove app icon from that and want to make its title center in action bar.
I have applied all solutions , but nothing is working with all the conditions.
Please give me some clue for applying it correctly
You should creat a customize action bar. Then, if you want you can add a button that can open and close your drawerlayout.
I have solved my problem. As mentioned, I have two problems, and I solved that in following way :
1) For making title centre, we need to make custom layout of action bar, and need to remove action bar title.
2) for remove app icon from action bar, we need to set android:icon property of that activity in manifest with transparent image or colour.
I have this screen structure in my app:
Which is tremendous waste of area. Mainly in the system bar and the action top bar.
I would like to:
Move the app logo and title to the system area
Narrow the height of the tabs
Move the menu to the bottom action bar
To get something like this:
You can do one thing remove the title and appicon from this TabLayout.
Use for your activity in androidmanifest.xml
android:theme="#android:style/Theme.NoTitleBar"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Using this parameters your layout will be looking like this see it
I managed to hide the main action bar. As it is described in Android Developer's site:
If you'd like to hide the main action bar at the top, because you're
using the built-in navigation tabs along with the split action bar,
call setDisplayShowHomeEnabled(false) to disable the application icon
in the action bar. In this case, there's now nothing left in the main
action bar, so it disappears and all that’s left are the navigation
tabs at the top and the action items at the bottom, as shown by the
second device in figure 3.
That's necessary, but not enough, because the main action bar still shows the title and the menu icon on the right. Two more steps are required:
Hide the icon and Title
setDisplayShowTitleEnabled(false);
Do not create a menu in onCreateOptionsMenu()
Now the main action bar is empty and it indeed dissapears. The tabs still show. The menu is lost, but you can create a button somewhere in your screen to act as menu, even you can use the same icon.
Tab Height
And I found out that the tab height can be controlled through XML style. Adding this to the styles.xml inside the app style tag
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarSize">35dp</item>
</style>
System Bar
It seems to be that the system bar is, as its name suggest, for system only use, not user. I did not find any clue to whether the elements in there can be modified (exception being notification icons from services)
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
Is it possible to use fragment tabs on action bar with the Theme.Holo.NoActionBar theme?
I mean... I already use this theme on my layouts but apparently it is overriden since the fragments have to show up in the action bar?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Is this possible?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Try calling setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar, and leave the theme alone.
You can style the action bar based on your needs. I'm quite certain you can also remove the app icon and title from there. Using a NoActionbar theme by default and then recreating the action bar on your own kinda defeats the purpose of the action bar. I suggest you use a theme with action bar and then style the bar according to your needs. This page has a decent implementation.