卸下底部阴影的动作条 - 机器人 [英] Removing bottom shadow on ActionBar - Android

查看:145
本文介绍了卸下底部阴影的动作条 - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用动作条的影子,但只能在一个活动。如果我用这个code这将是改变整个aplication。

I want to disable ActionBar shadow but only in one Activity. If I use this code it will be change in whole aplication.

<style name="MyAppTheme" parent="android:Theme.Holo.Light">
    <item name="android:windowContentOverlay">@null</item>
</style>

我想这code,但它不能正常工作

I tried this code, but it is not working

getSupportActionBar().setElevation(0);

任何建议...?

Any suggestion...?

推荐答案

您可以设置自己的风格的活动为这样的:

You can set your own style for Activity for this:

<!-- Your main theme with ActionBar shadow. -->
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
    ....
</style>

<!-- Theme without ActionBar shadow (inherits main theme) -->
<style name="MyNoActionBarShadowTheme" parent="MyAppTheme">
    <item name="windowContentOverlay">@null</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

所以的Manifest.xml可以设置不同的风格进行的所有活动:

So in Manifest.xml you can set different style for all Activities:

<!-- Activity with ActionBar shadow -->
<activity
    android:name=".ShadowActivity"
    android:theme="@style/MyAppTheme"/>

<!-- Activity without ActionBar shadow -->
<activity
    android:name=".NoShadowActivity"
    android:theme="@style/MyNoActionBarShadowTheme"/>

或者你也可以在编程的onCreate设置正确的主题()方法:

Or you can set the right theme programmatically in onCreate() method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.MyNoActionBarShadowTheme);
    super.onCreate(savedInstanceState);

    //...
}

这篇关于卸下底部阴影的动作条 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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