【问题标题】:Actionbar (android.support.v7) fills the entire screenActionbar (android.support.v7) 填满整个屏幕
【发布时间】:2014-01-15 11:13:24
【问题描述】:

我已经为 API 级别“7-13”和“14 及以上”提供了一个自定义主题,不同的 style.xml

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="actionBarStyle">@style/CustomTheme</item>
</style>

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <!-- Setting values in the default namespace affects API levels 7-13 -->
    <item name="background">@color/medium_turquoise</item>
</style>
<style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarSize">200dp</item>
</style>

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="homeAsUpIndicator">@drawable/back_button_actionbar</item>

我已将应用程序的主题设置为“@style/CustomTheme”,并在我的活动中设置了以下主题。

addView = getLayoutInflater().inflate(R.layout.actionbar, null);
getSupportActionBar().setCustomView(addView);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);

整个屏幕都被action bar占据了,我尝试改变高度但是没有用。我想我在风格上犯了一些错误。

谢谢

【问题讨论】:

    标签: android android-actionbar android-actionbar-compat


    【解决方案1】:

    您的代码对我来说似乎非常好。也许 Genymotion 没有正确渲染它。尝试在 sdk 中的实际设备或模拟器上运行它。

    还有一个建议,如果您在 android 中制作自定义主题,请尽量避免再次定义相同的样式属性。见下文

    <style name="CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <!-- Setting values in the default namespace affects API levels 7-13 -->
        <item name="actionBarStyle">@style/CustomTheme</item>
        <item name="background">@color/medium_turquoise</item>
        <item name="actionBarSize">200dp</item>
        <item name="homeAsUpIndicator">@drawable/back_button_actionbar</item>
    </style>
    

    【讨论】:

    • 您能否包含您的操作栏 xml 文件以更清晰?
    猜你喜欢
    • 1970-01-01
    • 2015-06-06
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    相关资源
    最近更新 更多