由网友(风吹乱浮生)分享简介:我怎样才能从Java code删除的操作栏中的阴影?How can i remove the drop shadow of action bar from java code ?.如果我删除它做工精细的风格。If i remove from the style it is working fine.我怎样才能从Java code删除的操作栏中的阴影?
How can i remove the drop shadow of action bar from java code ?.
如果我删除它做工精细的风格。
If i remove from the style it is working fine.
<style name="MyTheme" parent="Theme.Sherlock">
....
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
....
</style>
但我需要删除并动态地从Java code添加。
But i need to remove and add it dynamically from java code.
推荐答案
有没有办法设置值 windowContentOverlay
属性编程。但是你可以定义两个不同的主题,一个是有明显的动作条阴影活动,一个为他人:
There is no way to set value for windowContentOverlay
attribute programmatically. But you can define two different themes, one for Activities with a visible ActionBar shadow and one for others:
<!-- Your main theme with ActionBar shadow. -->
<style name="MyTheme" parent="Theme.Sherlock">
....
</style>
<!-- Theme without ActionBar shadow (inherits main theme) -->
<style name="MyNoActionBarShadowTheme" parent="MyTheme">
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
</style>
现在,你可以将其设置为活动的AndroidManifest.xml
:
Now you can set them to activities in AndroidManifest.xml
:
<!-- Activity with ActionBar shadow -->
<activity
android:name=".ShadowActivity"
android:theme="@style/MyTheme"/>
<!-- Activity without ActionBar shadow -->
<activity
android:name=".NoShadowActivity"
android:theme="@style/MyNoActionBarShadowTheme"/>
或者你也可以在的onCreate编程设置正确的主题()
方法:
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.MyNoActionBarShadowTheme);
super.onCreate(savedInstanceState);
//...
}
相关推荐
最新文章