如上题
toolbar布局代码
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:id="@+id/toolbar">
</android.support.v7.widget.Toolbar>
请输入代码
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
前提要确保Activity是appcompat中的ActionbarActivity或者兼容包下的其他activity类,在activity中设置setsupportactionbar(toolbar),否则你应该是只针对Android5版本的,用setActionbar()
在activity中设置setsupportactionbar(toolbar)
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat">
</style>
</resources>