johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.31k stars 564 forks source link

Add support for custom layouts #19

Closed johannilsson closed 13 years ago

johannilsson commented 13 years ago

We need this to be able to style the action bar differently on different activities. Currently it's quite hard to have two different looking action bars in the same project.

senagbe commented 13 years ago

Indeed, we have been trying to use a single ActionBar which changes colour in the same activity depending on the category of item being manipulated.

Using setBackgroundResource() doesn't work. Its even more of an issue for us as we wish to change the actionbar style in the same MapActivity (since you can only have one per project).

johannilsson commented 13 years ago

This is sort of a hack since Android does not support overriding styles at runtime (as far as I know).

It's setup like this;

<com.markupartist.android.widget.ActionBar
    android:id="@+id/actionbar"
    app:title="@string/some_title"
    app:actionBarBackground="@drawable/other_actionbar_background"
    app:actionBarItemBackground="@drawable/other_actionbar_item_btn"
    app:actionBarSeparator="@color/other_actionbar_separator"
    style="@style/ActionBar"
    />

For a full example see the example app. Also note that this is currently only available in the mimic-native-api branch.

senagbe commented 13 years ago

Thanks Johan, where are you based?

johannilsson commented 13 years ago

This has slightly changed if I recall correct though. There's however an example of this in the example app in the mimic-native-api branch of this, take a look at the styling of the OtherActivity.

I'm in Stockholm, Sweden.