Android Studio - Creating Material Design App Bar
1.) Set-up the color that we'll purpose for the app bar:
========================================
>Create a novel xml within values too refer it color.xml
<resources> <color name="ColorPrimary">#FF5722</color> <color name="ColorPrimaryDark">#E64A19</color> </resources>2.) Using the previously declared color, modify the style.xml to apply the colors:
=================================================================
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/ColorPrimary</item> <item name="colorPrimaryDark">@color/ColorPrimaryDark</item> <!-- Customize your subject here. --> </style> </resources>
3.) Make a tool bar:
================
>Create a novel xml layout file too refer it tool_bar.xml
<span style="font-size: x-small;"><?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/ColorPrimary" android:elevation="4dp" > </android.support.v7.widget.Toolbar> </span>
4.) Use the tool bar:
================
>Insert this code to wherever xml layout yous desire to display the tool bar
<include android:id="@+id/tool_bar" layout="@layout/tool_bar" ></include>
5.) Adding additional buttons within the app bar:
=======================================
>Go to menu_main.xml too add/paste the code below
<item android:id="@+id/action_user" android:orderInCategory="300" android:title="Android Studio - Creating Material Design App Bar" android:icon="@drawable/ic_launcher" app:showAsAction="ifRoom"></item>
0 komentar:
Please comment if there are any that need to be asked.