I want to make android custom app bar that contains searchbox, icon, etc.
The solution on google that I found was changing the style to no action bar. And create a toolbar layout that need to be included in every activity I made.
I just wondering, can I make custom App bar that default appear in every activity without including them when creating Activity?
I would recommend using v7.widget.toolbar. At first you need to create custom layout for your toolbar. Then you need to set it as a support action bar in each activity that you want it to appear. Toolbar on every activity can contains different icons.
https://developer.android.com/training/appbar/setting-up.html
Related
I have a simple app with just one activity. I'm trying to hide the navigation bar from the landscape version of the main activity's layout file.
I tried to find the specific attribute in AppCompat theme and create a custom style that would hide the bar from my layout but haven't found anything matching my goal. I know that it can be done in my activity's class code but I wonder if this is possible to set up in the layout file.
No way, you can hide navigation bar from swipe gesture in setting device.
I'm using one activity as a container and multiple fragments. Some of the fragments need to display app bar, some don't while others require to show a special app bar (e.g. an app bar that shrinks when swiping up). So where should I put the app bar (or action bar), in the activity or in the fragments?
By the way, if I put the app bar inside the fragments, how should I manage the app bars properly when fragments come in or move out?
if every fragment should have a different app bar, you probably want to use a Toolbar.
Toolbar is a standalone ActionBar that you can put anywhere, in any view group. The Toolbar API is roughly the same as the ActionBar one, so you should not have any major issue migrating to Toolbar.
For your app, you should have Toolbar in every fragment, when needed and every fragment control it's own Toolbar.
Now I have my nifty custom title bar in its own XML layout file and I've got my custom theme and style XML files. From my Activity class I can invoke it and it looks great.
Problem is my app has 14 Activities, each with their associated layout file. If I want to see the same title bar appear across my app, i.e., in all my Activities, the two main strategies I've seen are:
Put a an <include layout="#layout/my_title_bar" /> for my title bar in every layout file
...or...
Change all my Activity classes to derive from some common Activity that invokes the new title bar
Before I go off and do one of these I just want to make sure there's no more "centralized' way of doing it, like, say, in the manifest. There's no need to declare the default title bar in every activity, and it doesn't seem right to have to make separate changes for each activity for an app-wide feature like a custom title bar.
Thanks in advance for any tips!
I am trying to find the name of the built in widget that is used to make the static bar at the top of the Skype app for Android. Does anyone know? I think it adds easy button functionality.
Also, how within that bar they have a button to change the user's status. It pops up a pretty bubble with an animation. Is this something built into a library or custom?
The action bar wasn't included until 3.0 as its the same app thats used for both tablets and smartphones, and on a tablet, the menu is still present, not shifted to where the action bar should be.
Its more likely they have each activities content in a scrollview, and a static layout pinned to the top of the page,
If you make your activities that will be using the top bar extend a base activity class that includes handlers for the static layout at the top of each page, and define the layout separately to be included in each activity's layout where it is required.
As for the bubble that animates out, it will be part of the layout but hidden, or not part of the layout, but inflated from xml pragmatically. i dont know what the exact animation is that makes it zoom in from the center though. The actual bubble will be another layout, wrapped in a FrameLayout so i sits nicely on top of the current activities layout.
Hope some of this was helpful
Check out ActionBarSherlock for a library that lets you easily implement action bar on pre-Honeycomb devices.
The static bar thar you are talking about is the action bar. It's included as standard in the version 3.0 of the API but you can also use libraries that provides you a very likely widget.
I use a modified version of GreenDroid library... You can also install the GreenDroid Catalog application from the Market to take a look.
Ah! of course you can change the color using styles!
I recently thought of adding a custom title bar to my app (with "find me" and home button and such) and then I thought what is the reason of using a custom title bar at top instead of just a normal layout and using it as an include tag at the top of my XML's
What are the pros and cons of each? Is there realy a difference?
EDIT: one difference ive found so far is that the custom title bar has a shadows automaticly
For having back and home button titlebar, you should define normal layout for the same. Because it is easy to implement as compared to customized the native title bar. And we can create normal layout as we wants with any color/height/width/image backround/etc.
I suggest you to go with defining normal layout for the title bar instead of customizing the native title bar.
You can extend LinearLayout to create a new layout with your title bar. The advantage is you can then customise the title bar for different activities that use it. Some may not want to display the find button for instance.
If you use include in XML you don't have the same flexibility.
I would create a custom layout with the title bar.