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.
Related
Im making an app for android, without actionbar.
What is best practice for showing titles without actionbar?
The best practice is basically never using an action bar. This gives you a complete device screen to play with.
You can use images or different text styles for showing the title. You can also use interesting icons.
To remove action bar -
Go to res > values > styles.xml
Here is an illustration of styles file -
You can use the Toolbar (it's like the action bar, but more flexible). For example, action bar needs to be on top of the screen, but toolbar can have place anywhere in the layout.
You title can be shown as text or a beautiful asset.
If, for some reason, you don't want to use the toolbar, you can think about something like having a scrollView with the title on top of it.
Use a regular LinearLayout with a TextView inside. Style according to your needs, and set the text in the xml, or programmaticaly using TextView's setText() method.
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.
I want this type of custom title bar
But can anyone tell me what the portion marked with red is made of? I mean are they tabs or image buttons or something else? Please don't give me links on how to apply a custom title bar, I already know it. But I don't know what the red-marked portion is (tabs or image buttons etc) And how can I have that vertical line between Search and Make Video option (in the portion that's marked red) I'm using Gingerbread.
I tried using search engines but how can I search when I don't know the name of the thing I want to search :s
They are called ActionBar Action Items. See: http://developer.android.com/guide/topics/ui/actionbar.html\
As for dividers, take a look at: ActionBar MenuItem Divider
You should to use ActionBarSherlock.
http://actionbarsherlock.com/
This is for add actionbar in devices android <3.x.
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.
There is a situation in which I want to use Tab bar as well as List navigation, Both at same time in Action bar.
Documentation says 'we can put Actionbar in to list navigation mode or tabs navigation mode'.
Is there any way to use both at same time. Any pointers, help. Thank you in Advance.
Sorry, you can only have one or the other.
That being said, you can use android:actionLayout to convert an options menu item into a custom inflated layout in the action bar. You might be able to use the "tabs navigation mode" while putting your own Spinner to the right of the tabs this way. Personally, I would find this confusing as a user, but perhaps it will work for your use case.
a very late answer, but this is possible by a simple hack. You just have to replace (programatically) the view that is pointed by android.R.id.action_bar_title with a Spinner. I wrote a blog about it. Here's the link