I would like to add one of the menu icons of the action bar as below.
I need an icon and a bubble on top of that and I need to display a number on that at run time.
Is it possible to do? I have Googled regarding this, but couldn't find exact way to do.
Thanks in advance.
what you want is call "badge"
A simple way to "badge" any given Android view at runtime without having to cater for it in layout.
try this Lib
https://github.com/jgilfelt/android-viewbadger
You will have to define custom layout for your action bar as mentioned in the tutorial here
and to display counter above the Imageview android notification class can be used.
Related
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'm new in android programming, I want to create the GUI of my app, when making that the action bar must be customized to looks like :
here i have "three" things:
the button shape in the non-clicking state.
the button shape in the clicking state.
the buttons separator shape.
while searching i found somethings like Android-actionbar and ActionBar-Sherlock and i'm also familiar with how to customize the action bar and how to add buttons imagess and change it upon clicking, NOW, i don't know if there's is possibility to achieve my work using any of these methods, OR IF NOT, what's the best way.
You should take a look at both these links.
PagerTabStrip
ViewPagerIndicator
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 developing an application in which I have to put drawables on top of the actionbar and have to update then from time to time. Here is a layout what I want it to look like.
I want to put a drawable as shown in the picture atttached(The green color drawable not the notification thing). Is that possible to achieve this kind of screen in android? If, so please guide me how to achieve this.
Any kind of help will be appreciated.
This is easy using a custom view. Let me explain you the steps briefly:
Create your custom view in the layout folder. For example, an ImageButton.
Set this view as the custom view of the action bar in your activity. You can do this by calling
getSupportActionBar().setCustomView(R.layout.your_custom_view);
(or getActionBar() instead of getSupportActionBar())
Call setDisplayOptions() with the ActionBar.DISPLAY_SHOW_HOME and ActionBar.DISPLAY_SHOW_CUSTOM options.
If you have other standard buttons in the action bar, inflate the menu.
You can finally set the OnClickListener for your custom view.
This worked for me, hope it helps you!
Create custom view
Use it as ActionView in ActionBar
In onCreateOptionsMenu get a reference to your view and update it when needed
I want to show Action Bar like below.
I have already used this library clickhere
But it takes only two icons on Action Bar. If I add four items, then last two are shown me like menu. I want all in Action bar same as image above.
Is it possible? if yes, then HOW? Can I change Action Bar color or its default style available in Device?
Thanks in Advance.
I recommend you use this:
http://jgilfelt.github.com/android-actionbarstylegenerator/
to style your ActionBar.
If you want all the 4 icons to be there, just add this attribute to all the menu items:
android:showAsAction="always"
hello try this library
it sure help you And you may have to add you own logic to handle this in below 2.3 Android OS and above 3.0 Android OS.
there is many demo sample available like below :
There is no way you can be sure of the number of icons displayed in the action bar. There is a large varierty of Android devices out there and they all have different screen sizes. That's why you have to prioritize the actions available in a menu : the most important will be displayed as actions in the action bars and the others will be displayed in the "menu" : the action overflow.
You should think of actions in a functional way, not a graphical way.
With ref to Image that you attached you should decide which design pattern you want to use in your application, there are many UI patterns available for mobiles, tablets. The image you attached looks like Side Navigation UI pattern. It's better you decide which UI pattern perfect for your app.. then start implementing it with custom action bar libs (if you want action bar in less than Android 3.0 ver) or any other.