I have an action bar in my activity, declared as following:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.hamburger);
and my xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.wega.mcfc.DashboardActivity" >
<!-- Main Content -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
...
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
I just recently tried my app on an older Android version (4 instead of 6) and the toolbar is not showing anymore, is there something else I'm supposed to do for it to work?
Is it support toolbar layout? ie
<android.support.design.widget.AppBarLayout
android:theme="@style/AppTheme.AppBarOverlay">
...
...
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
...
... />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.