ibm123
ibm123

Reputation: 1254

Android action Bar customization

my app is using using Sherlock action bar. my designer gave me a new design.

  1. the app logo need to be in the middle
  2. 2 action items to the left and 2 actionitems to the right of the logo
  3. the app logo height is 1.5 the size of the actionbar (it suppose to be a little overflow)

is it possible to create a custom layout for the actionbar to implement this desing ? or should i remove my actionbar and implement the design my own ?

if item #3 will be optional , does it changes your answers ?

Thanks

Upvotes: 6

Views: 1235

Answers (5)

user3102484
user3102484

Reputation: 1

You could create a RelativeLayout, with your icon in the center

centerInParent="true"

Then in the same layout, you could create a background, with width set to fill_parent, and the height to 2/3 the size of your center icon (calculating this value in DP).

Upvotes: -1

Bostone
Bostone

Reputation: 37154

Please forward your designer, and your manager to Android design patterns site at http://developer.android.com/design/patterns/actionbar.html . Also tell them that if they want Google to ever feature them, they pretty much have to adhere to these. With all failed use full screen layout and create a custom control on the top

Upvotes: 3

Booger
Booger

Reputation: 18725

If you want to implement this (and I pretty much agree with the other posters, that this is non-standard, and probably shouldn't be done).

You won't be able to create this style ActionBar with the standard APIs (or ActionBarSherlock for that matter) - since your UI is non-standard

You could create a RelativeLayout, with your icon in the center (centerInParent="true"). Then in the same layout, you could create a background, with width set to "fill_parent", and the height to 2/3 the size of your center icon (calculating this value in DP).

Then you can create ImageButtons for your 2 ActionItems to the left and to the right, then just put them in your layout relative to the center icon.

Bottom line, you probably should re-think your UI, to make this more standard to the design patterns specified by Android. If you still want to do it the way your designer asks, you will need to do a custom layout (using a RelativeLayout as I suggested is one way to accomplish the UI you are looking for).

Upvotes: 1

Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28563

I agree with other answers: that's not an action bar as defined by Android guidelines.

I'll just add that in case you can't go against the design decisions made (yeah, real-world projects sometimes suck and as a programmer you'll have to do what the client asks).

Go with your own implementation. I suggest simply creating a fragment with the appropriate listener interface (a common Android pattern, let the activity implement the interface, set the fragment's listener in onAttach).

Upvotes: 2

Wolfram Rittmeyer
Wolfram Rittmeyer

Reputation: 2402

I'm sorry, but kick your designer in the...

He doesn't get Android at all and shouldn't design for Android. Either it's an ActionBar and then you should treat is as such and you (or your designer) should follow the common pattern on Android, or it is not.

If it is no ActionBar, please do not use an ActionBar (no matter which library) and create a custom design that deviates enough from an ActionBar so as not to confuse users!

Upvotes: 38

Related Questions