public class MyActivity extends AppCompatActivity { // ... }
AndroidManifest.xml
<application android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(myToolbar); }
Update 11/20/2017
This seems a better approach :
Note that this code generate Toolbar with white text and icons
<android.support.design.widget.AppBarLayout android:id="@+id/appBarLayoutSelectLabTest" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbarSelectLabTest" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout>
References
https://developer.android.com/training/appbar/setting-up.html
https://stackoverflow.com/questions/30178727/set-menu-overflow-icon-to-be-white