Action Bar Sherlock with buttons - android

i'm building an app and i really want to align buttons to the left using ABS (action bar sherlock) 4.0
I really like the dropbox interface as shown under this:
So, my question is: How can i align the buttons to the left and how can i jump between views in ViewFlow using buttons?
I've seen that people can add tabs to their ABS, but not with the title like the Dropbox interface.
Thanks.
Also if u need my sourcecode i will add it later if needed.
Regards
Stian Instebø

setCustomView() is the magic method you might be looking for.
To achieve the same layout shown in the Dropbox app, you would first call setDisplayShowHomeEnabled(false) on your ActionBar.
Next, you could define the layout for the buttons somewhere in XML. Once this is done, calling setCustomView(R.layout.my_actionbar_nav) will do the trick. (It will now be positioned on the left-hand side of the ActionBar).
It'll be your responsibility to wire up the appropriate onClick listeners for your layout's inner button Views, but it's not a bad price to pay for setting up custom navigation.

Related

How to position the elements in a custom action bar layout in Android?

I need to develop a custom layout for the action bar in Android.
I'm now stuck because I have no clue how to calculate the available space for my custom layout.
In the image, the red part is my custom layout, the blue part is the space occupied by the action buttons.
Clearly I need to know/calculate the size of the red part to be able to correctly position the elements in my custom action bar (for example center the title in the window or make sure not to overflow in the blue part).
How can I achieve this?
I couldn't find useful examples or a clear API in the Android documentation.
I think that anyone using the custom action bar layout must be facing this kind of problem, I'm a bit confused.
Or am I supposed not to use action buttons in this case? Perhaps I'm supposed to replicate the action buttons by myself?
Thanks in advance
Try using ToolBar instead of ActionBar. It will give you a lot more control over ActionBar elements than ActionBar.
Here is a simple tutorial about how to replace ActionBar with ToolBar and how you can customise it.
Material ToolBar
Possibilities are endless with ToolBar but my recommendation is to don't overdo anything.
As per my suggestion try to use the entire action bar by your custom layout. So that you can arrange all the things use it as a fragment inside a framelayout for all your screens so that the code can be reused for all your layouts.

ActionBar in android at bottom

I want to put an action bar with 4 clickable entities, on the bottom of the activity. I should be able to associate each of the 4 entities/buttons with intents. Can anyone please tell me the xml file and the java code for this. I am not able to find this anywhere.
You can try a SplitActionBar but in general it is recommended that the ActionBar be at the top and contactual actions go in the bottom bar.
Alternatively you can try playing with the gravity layout parameter as shown here, though I have not tried this and would advise against it.

Action bar Action Item location

I'm currently creating an app where it would be useful for the user to have all the options in the actionbar.
This is the current situation:
As you can see, Item1 and Item2 are on the right but I'd like to have these on the left side.
Is this possible?
If it is not possible, how would I simulate what I want?
An ImageView with Buttons functioning as the ActionBar?
I had a similar issue but I wanted something on the left, something in the middle, and overflow on the right. I created a custom layout with three ImageButtons for the three elements. Then used an <include> tag to include this layout in my Activities xml files.
I also created a BaseActivity for my other Activities to extend and put the menu functionality in there like OnMenuItemClickListener() then I could just override them in my Activities if I needed different functionality for a certain Activity aside from what it did in the BaseActivity. I also used PopupMenu here (requires API >= 11).

Creating an Android Nav Bar that replaces button with image when that activity is active

I am looking to create a Nav Bar in my Android application that functions very similar to the Nav Bar used by the Netflix app. There will be 4 buttons aligned horizontally. When one of those buttons is selected, the appropriate activity loads and that button is replaced by an image.
There are multiple ways I can achieve this, but since I am new to programming for Android, I figured I'd ask the community first. I list the first two that come to my head below.
Create a Linear Layout and define a separate layout for each activity. The Layout would include two more linear layouts, a horizontal linear layout for the nav bar and a vertical layout for the content.
Create a custom ui component named nav bar that extends a linear layout (based upon earlier threads I have seen about nav bars on here). Inflate that layout for each activity, then make a framelayout that overlays an image on top of the active button (the button that was just pressed). Then create onButtonClick listeners for each button except for the active button.
I'm not sure if there is a better way to achieve this and I am open to any suggestions. Any feedback would be great.
I'm not sure how the netflix app looks, but you might want to check out ye good olde tab-layout? ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html )
Also be sure to take a look at the android design page: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

How Does Skype Do The Android View At The Top?

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!

Categories

Resources