KiK*_*iKo 9 android android-actionbar
我想禁用ActionBar
阴影但只在一个Activity
.如果我使用此代码,它将在整个应用程序中进行更改.
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我尝试了这段代码,但它没有用
getSupportActionBar().setElevation(0);
Run Code Online (Sandbox Code Playgroud)
有什么建议......?
Suv*_*ica 18
您可以为此设置自己的活动样式:
<!-- 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>
Run Code Online (Sandbox Code Playgroud)
因此,在Manifest.xml中,您可以为所有活动设置不同的样式:
<!-- Activity with ActionBar shadow -->
<activity
android:name=".ShadowActivity"
android:theme="@style/MyAppTheme"/>
<!-- Activity without ActionBar shadow -->
<activity
android:name=".NoShadowActivity"
android:theme="@style/MyNoActionBarShadowTheme"/>
Run Code Online (Sandbox Code Playgroud)
或者,您可以在onCreate()方法中以编程方式设置正确的主题:
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.MyNoActionBarShadowTheme);
super.onCreate(savedInstanceState);
//...
}
Run Code Online (Sandbox Code Playgroud)
Ujj*_*wal 10
将app:elevation ="0dp"添加到appbarlayout,如下所示:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/home_tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
创建一个继承App主题的新主题:
<style name="MyAppTheme.NoShadow" parent="MyAppTheme">
<item name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并让您的活动使用此主题.在你的清单中:
<activity
android:name="...MyShadowlessActivity"
android:theme="@style/MyAppTheme.NoShadow" .../>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16878 次 |
最近记录: |