V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
michaelye1988
V2EX  ›  问与答

一个 Android ActionBar 相关的问题,程序使用了 support-v7-appcompat 这个包。和下面链接中遇到的问题一样。

  •  
  •   michaelye1988 · 2014-11-24 10:00:32 +08:00 · 2427 次点击
    这是一个创建于 3440 天前的主题,其中的信息可能已经有所发展或是发生改变。
    发现在启动的时候会加载 Android 默认的 style,而且这个 style 不能被自己的 style 覆盖掉。

    http://segmentfault.com/q/1010000000125004
    第 1 条附言  ·  2014-11-24 11:28:55 +08:00
    我的解决办法:

    <style name="MainActivityStyle" parent="Theme.AppCompat.Light">
    <item name="android:icon">@android:color/transparent</item>
    <item name="@android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
    </style>

    <style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">;
    <item name="@android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
    <item name="android:height">@dimen/action_bar_height</item>
    <item name="android:background">@color/back_ground_purple</item>
    </style>

    <activity
    android:name="com.michael.picture.MainActivity"
    android:screenOrientation="portrait"
    android:theme="@style/MainActivityStyle" >
    6 条回复    2014-11-24 17:55:15 +08:00
    GhostFlying
        1
    GhostFlying  
       2014-11-24 11:23:00 +08:00 via Android   ❤️ 1
    怎么会,继承 AppCompat.Light.NoActionBar 主题就可以了
    zhoulujue
        2
    zhoulujue  
       2014-11-24 11:25:05 +08:00
    我去,我也是这样。在manifest里面指定了NoActionBar各种属性,都不管用。
    michaelye1988
        3
    michaelye1988  
    OP
       2014-11-24 11:25:52 +08:00
    @GhostFlying 感谢,是我弄错了,熬夜写代码犯迷糊了,今天早上再检查了一下代码,是可以覆盖掉系统默认的主题的。
    michaelye1988
        4
    michaelye1988  
    OP
       2014-11-24 11:26:42 +08:00
    @zhoulujue 应该是可以的,你再检查下代码。
    zhoulujue
        5
    zhoulujue  
       2014-11-24 11:46:25 +08:00
    @michaelye1988 搞定,application也应该同时指定属性。
    michaelye1988
        6
    michaelye1988  
    OP
       2014-11-24 17:55:15 +08:00
    @zhoulujue nice
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   982 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:38 · PVG 05:38 · LAX 14:38 · JFK 17:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.