AppCompat动作条造型 [英] AppCompat Actionbar styling

查看:95
本文介绍了AppCompat动作条造型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用AppCompat而不是ActionbarSherlock。在Android 4+设备我就不会遇到任何问题,因为正常的动作条​​和全息主题被使用。

I'm currently trying to use AppCompat instead of ActionbarSherlock. On Android 4+ devices I don't run into any problems, as the normal Actionbar and Holo theme are used.

在低版本的Andr​​oid然而,这种怪异的外观采用Theme.AppCompat.Light时发生。

On lower Android versions however, this weird look happens when using Theme.AppCompat.Light.

在ActionBar是白色的,有蓝线下方。

The Actionbar is white and has a blue line underneath.

我能够修复使用从Android的资产工作室Android的动作栏样式生成器生成自定义主题具有扎实的ActionBar,而不是透明的。

I was able to fix that by using the Android Action Bar Style Generator from Android Asset Studio to generate a custom theme with a solid Actionbar instead of the transparent one.

当比较它的动作条我用ActionbarSherlock的时候,它仍然是一种丑陋的,但。

When comparing it to the Actionbar I got when using ActionbarSherlock, it's still kind of ugly though.

的AppCompat动作条具有这种非常清晰,黑色本身和活动的内容之间线路,而股票动作条的ICS或ActionbarSherlock中的一个具有从动作条到布局较软的过渡

The AppCompat Actionbar has this very sharp, black line between itself and the content of the activity, while the stock Actionbar of ICS or the one of ActionbarSherlock have a softer transition from the Actionbar to the layout.

如何样式的动作条真的看起来像一个在安卓4.0 +?

How can I style the Actionbar to really look like the one on Android 4+?

推荐答案

您必须用你想放的背景图像创建你自己的风格。在您的style.xml,你应该建立类似这样:

You have to create your own style with the image you want to put on background. In your style.xml, you should create something similar to this:

值/ styles.xml

    <style name="Theme.MyAppTheme" parent="@style/Theme.AppCompat.Light">
        <item name="actionBarStyle">@style/ActionBarTabStyle.MyAppTheme</item>
    </style>

    <style name="ActionBar.Solid.MyAppTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="background">@drawable/your_background_image</item>
    </style>

值-V14 / styles.xml

    <style name="Theme.MyAppTheme" parent="@style/Theme.AppCompat.Light">
        <item name="android:actionBarStyle">@style/ActionBarTabStyle.MyAppTheme</item>
    </style>

    <style name="ActionBar.Solid.MyAppTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="android:background">@drawable/your_background_image</item>
    </style>

和您可以使用此9片图像:

and you can use this 9-patch image :

这篇关于AppCompat动作条造型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆