简体   繁体   中英

Custom action bar show dark padding left after upgrade project to Android SDK version 21

I have just upgraded my project to Android SDK version 21 today. I increase the version of android support appcompat v7 to 21.0.0. I was through that everything will be ok, and it should be ok. But after all of that, the action bar start show a dark padding on the left.

I am using custom action bar (DISPLAY_SHOW_CUSTOM)

Screenshots are bellow:

Before: http://imgur.com/Hw4waxZ

After: http://imgur.com/OjI4fse

How can I fix this issue?

After a few weeks now I finally figured it out! You need to create a custom ActionBar Theme setting Left and Right Inset to 0dp like this:

<style name="CustomLightTheme.ActionBar" parent="Widget.AppCompat.ActionBar">
    <item name="contentInsetStart">0dp</item>
    <item name="contentInsetLeft">0dp</item>
</style>

and then use the theme like this:

<item name="actionBarStyle">@style/CustomLightTheme.ActionBar</item>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM