V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
michaelye1988
V2EX  ›  问与答

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

  •  
  •   michaelye1988 · Nov 24, 2014 · 2986 views
    This topic created in 4177 days ago, the information mentioned may be changed or developed.
    发现在启动的时候会加载 Android 默认的 style,而且这个 style 不能被自己的 style 覆盖掉。

    http://segmentfault.com/q/1010000000125004
    Supplement 1  ·  Nov 24, 2014
    我的解决办法:

    <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 replies    2014-11-24 17:55:15 +08:00
    GhostFlying
        1
    GhostFlying  
       Nov 24, 2014 via Android   ❤️ 1
    怎么会,继承 AppCompat.Light.NoActionBar 主题就可以了
    zhoulujue
        2
    zhoulujue  
       Nov 24, 2014
    我去,我也是这样。在manifest里面指定了NoActionBar各种属性,都不管用。
    michaelye1988
        3
    michaelye1988  
    OP
       Nov 24, 2014
    @GhostFlying 感谢,是我弄错了,熬夜写代码犯迷糊了,今天早上再检查了一下代码,是可以覆盖掉系统默认的主题的。
    michaelye1988
        4
    michaelye1988  
    OP
       Nov 24, 2014
    @zhoulujue 应该是可以的,你再检查下代码。
    zhoulujue
        5
    zhoulujue  
       Nov 24, 2014
    @michaelye1988 搞定,application也应该同时指定属性。
    michaelye1988
        6
    michaelye1988  
    OP
       Nov 24, 2014
    @zhoulujue nice
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2541 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:42 · PVG 16:42 · LAX 01:42 · JFK 04:42
    ♥ Do have faith in what you're doing.