Beranda Android Membuat Bottom Tabs Animasi

Membuat Bottom Tabs Animasi

0
746

Navigation Drawer With Animation Bottom Tabs – Kali ini saya akan membagikan tutorial membuat navigation drawer dengan tabs bottom dan apabila tabnya digeser akan ada animasi.

Ok langsung saja buatlah sebuah project baru dan pilih empty ,setelah itu salin kode beeikut dan pastekan di dependency Build.gradle

dependencies {
	
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.3'
    testCompile 'junit:junit:4.12'

    // Google Material Design
    compile 'com.android.support:design:25.0.3'
    // custom tab layout
    compile 'eu.long1:spacetablayout:1.0.4'
    // circle image view
    compile 'de.hdodenhof:circleimageview:2.1.0'
    // material Statusbar
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    // material search bar
    compile 'com.miguelcatalan:materialsearchview:1.4.0'


}

Setelah itu letakan kode berikut di activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <FrameLayout
            android:id="@+id/toolbar_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentTop="true"
        android:layout_gravity="center"
        android:gravity="center"
        android:title="@string/chats_toolbar"
        android:titleTextAppearance="@style/Toolbar.TitleText"
        android:background="@color/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:popupTheme="@style/AppTheme.PopupOverlay"/>

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        </FrameLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="56dp" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginTop="16dp"
        android:layout_marginBottom="64dp"
        android:layout_marginRight="16dp"
        android:layout_marginLeft="16dp"
        android:src="@drawable/ic_action_add" />

    <eu.long1.spacetablayout.SpaceTabLayout
        android:id="@+id/spaceTabLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_behavior="eu.long1.spacetablayout.SpaceTabLayoutBehavior"
        app:number_of_tabs="three"
        app:starting_position="two"
        app:tab_color="@color/colorPrimary"
        app:button_color="@color/md_light_blue_400"
        app:text_one=""
        app:text_two=""
        app:text_three=""
        app:icon_one="@drawable/ic_contacts"
        app:icon_two="@drawable/ic_tab_one"
        app:icon_three="@drawable/ic_profile"/>

</android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        app:itemIconTint="@color/colorPrimary"
        app:itemTextColor="@color/md_black_1000"
        android:textAlignment="center"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/menu_navigation"/>

    <!--  app:itemTextAppearance="@style/NavigationDrawerStyle"-->

</android.support.v4.widget.DrawerLayout>

Lalu buatlah sebuah layout dan diberi nama fragment_a.xml dan pastekan kode berikut

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="anindya.sample.materialbottomtab.anindya.sample.bottom_tab_and_navigation.FragmentA">

    <!-- TODO: Update blank fragment layout -->
    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/ic_loyalty_black_24dp" />

</RelativeLayout>

Buat sebuah layout lagi diberi nama fragment_b.xml,dan pastekan kode berikut

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="anindya.sample.materialbottomtab.anindya.sample.bottom_tab_and_navigation.FragmentB">

    <!-- TODO: Update blank fragment layout -->
    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/ic_keyboard_capslock_black_24dp" />

</RelativeLayout>

Masih buat sebuah layout diberi nama fragment_c.xml,dan letakan kode berikut

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="anindya.sample.materialbottomtab.anindya.sample.bottom_tab_and_navigation.FragmentC">

    <!-- TODO: Update blank fragment layout -->
    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/ic_fingerprint_black_24dp" />

</RelativeLayout>

Buat sebuah layout dan diberi nama nav_header.xml,dan pastekan kode berikut

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:background="@color/colorPrimary"
    android:orientation="vertical">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/profile_image"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:src="@drawable/selfie" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center"
        android:layout_marginTop="10dp"
        android:gravity="center">

        <TextView
            android:id="@+id/user_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Amelia Silvia"
            android:textColor="@color/md_white_1000"
            android:textSize="16sp"/>

    </LinearLayout>

</LinearLayout>

Setelah itu buatlah file xml di folder drawable diberi nama ic_fingerprint_black_24dp.xml dan pastekan kode berikut

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M17.81,4.47c-0.08,0 -0.16,-0.02 -0.23,-0.06C15.66,3.42 14,3 12.01,3c-1.98,0 -3.86,0.47 -5.57,1.41 -0.24,0.13 -0.54,0.04 -0.68,-0.2 -0.13,-0.24 -0.04,-0.55 0.2,-0.68C7.82,2.52 9.86,2 12.01,2c2.13,0 3.99,0.47 6.03,1.52 0.25,0.13 0.34,0.43 0.21,0.67 -0.09,0.18 -0.26,0.28 -0.44,0.28zM3.5,9.72c-0.1,0 -0.2,-0.03 -0.29,-0.09 -0.23,-0.16 -0.28,-0.47 -0.12,-0.7 0.99,-1.4 2.25,-2.5 3.75,-3.27C9.98,4.04 14,4.03 17.15,5.65c1.5,0.77 2.76,1.86 3.75,3.25 0.16,0.22 0.11,0.54 -0.12,0.7 -0.23,0.16 -0.54,0.11 -0.7,-0.12 -0.9,-1.26 -2.04,-2.25 -3.39,-2.94 -2.87,-1.47 -6.54,-1.47 -9.4,0.01 -1.36,0.7 -2.5,1.7 -3.4,2.96 -0.08,0.14 -0.23,0.21 -0.39,0.21zM9.75,21.79c-0.13,0 -0.26,-0.05 -0.35,-0.15 -0.87,-0.87 -1.34,-1.43 -2.01,-2.64 -0.69,-1.23 -1.05,-2.73 -1.05,-4.34 0,-2.97 2.54,-5.39 5.66,-5.39s5.66,2.42 5.66,5.39c0,0.28 -0.22,0.5 -0.5,0.5s-0.5,-0.22 -0.5,-0.5c0,-2.42 -2.09,-4.39 -4.66,-4.39 -2.57,0 -4.66,1.97 -4.66,4.39 0,1.44 0.32,2.77 0.93,3.85 0.64,1.15 1.08,1.64 1.85,2.42 0.19,0.2 0.19,0.51 0,0.71 -0.11,0.1 -0.24,0.15 -0.37,0.15zM16.92,19.94c-1.19,0 -2.24,-0.3 -3.1,-0.89 -1.49,-1.01 -2.38,-2.65 -2.38,-4.39 0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5c0,1.41 0.72,2.74 1.94,3.56 0.71,0.48 1.54,0.71 2.54,0.71 0.24,0 0.64,-0.03 1.04,-0.1 0.27,-0.05 0.53,0.13 0.58,0.41 0.05,0.27 -0.13,0.53 -0.41,0.58 -0.57,0.11 -1.07,0.12 -1.21,0.12zM14.91,22c-0.04,0 -0.09,-0.01 -0.13,-0.02 -1.59,-0.44 -2.63,-1.03 -3.72,-2.1 -1.4,-1.39 -2.17,-3.24 -2.17,-5.22 0,-1.62 1.38,-2.94 3.08,-2.94 1.7,0 3.08,1.32 3.08,2.94 0,1.07 0.93,1.94 2.08,1.94s2.08,-0.87 2.08,-1.94c0,-3.77 -3.25,-6.83 -7.25,-6.83 -2.84,0 -5.44,1.58 -6.61,4.03 -0.39,0.81 -0.59,1.76 -0.59,2.8 0,0.78 0.07,2.01 0.67,3.61 0.1,0.26 -0.03,0.55 -0.29,0.64 -0.26,0.1 -0.55,-0.04 -0.64,-0.29 -0.49,-1.31 -0.73,-2.61 -0.73,-3.96 0,-1.2 0.23,-2.29 0.68,-3.24 1.33,-2.79 4.28,-4.6 7.51,-4.6 4.55,0 8.25,3.51 8.25,7.83 0,1.62 -1.38,2.94 -3.08,2.94s-3.08,-1.32 -3.08,-2.94c0,-1.07 -0.93,-1.94 -2.08,-1.94s-2.08,0.87 -2.08,1.94c0,1.71 0.66,3.31 1.87,4.51 0.95,0.94 1.86,1.46 3.27,1.85 0.27,0.07 0.42,0.35 0.35,0.61 -0.05,0.23 -0.26,0.38 -0.47,0.38z"/>
</vector>

Lalu buat sebuah xml lagi dan diberi nama ic_keyboard_capslock_black_24dp.xml,dan pastekan kode berikut

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M12,8.41L16.59,13 18,11.59l-6,-6 -6,6L7.41,13 12,8.41zM6,18h12v-2H6v2z"/>
</vector>

Masih buat xml lagi di folder drawable dan diberi nama ic_loyalty_black_24dp.xml,dan pastekan kode berikut

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M21.41,11.58l-9,-9C12.05,2.22 11.55,2 11,2L4,2c-1.1,0 -2,0.9 -2,2v7c0,0.55 0.22,1.05 0.59,1.42l9,9c0.36,0.36 0.86,0.58 1.41,0.58 0.55,0 1.05,-0.22 1.41,-0.59l7,-7c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-0.55 -0.23,-1.06 -0.59,-1.42zM5.5,7C4.67,7 4,6.33 4,5.5S4.67,4 5.5,4 7,4.67 7,5.5 6.33,7 5.5,7zM17.27,15.27L13,19.54l-4.27,-4.27C8.28,14.81 8,14.19 8,13.5c0,-1.38 1.12,-2.5 2.5,-2.5 0.69,0 1.32,0.28 1.77,0.74l0.73,0.72 0.73,-0.73c0.45,-0.45 1.08,-0.73 1.77,-0.73 1.38,0 2.5,1.12 2.5,2.5 0,0.69 -0.28,1.32 -0.73,1.77z"/>
</vector>

Lalu di folder menu buatlah sebuah xml,diberi nama menu_navigation,kalau belum ada folder menu buatlah sebuah folder dan siberi nama menu,dan salin kode berikut dan pastekan

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <!--    <group android:checkableBehavior="single">-->
    <group android:id="@+id/core">
        <item
            android:id="@+id/home"
            android:title="Home"
            android:icon="@drawable/ic_action_android"/>

        <item
            android:id="@+id/friends"
            android:title="Friends"
            android:icon="@drawable/ic_action_android"/>

        <item
            android:id="@+id/profile"
            android:title="Profile"
            android:icon="@drawable/ic_action_android"/>
    </group>

    <group android:id="@+id/extra">
        <item
            android:id="@+id/settings"
            android:title="Settings"
            android:icon="@drawable/ic_action_android"/>

        <item
            android:id="@+id/help"
            android:title="Help"
            android:icon="@drawable/ic_action_android"/>

        <item
            android:id="@+id/logout"
            android:title="Logout"
            android:icon="@drawable/ic_action_android"/>
    </group>

</menu>

Masih di folder menu,buatlah sebuah file xml dan diberi nama toolar_menu dan pastekan kode berikut

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_action_action_search"
        android:orderInCategory="100"
        android:title="@string/abc_search_hint"
        app:showAsAction="always" />
</menu>

Di folder res/value/colors.xml pastekan kode berikut

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#f44336</color>
    <color name="colorPrimaryDark">#D50000</color> <!--#f44336-->
    <color name="colorAccent">#f44336</color>

    <!--reds-->
    <color name="md_red_50">#FFEBEE</color>
    <color name="md_red_100">#FFCDD2</color>
    <color name="md_red_200">#EF9A9A</color>
    <color name="md_red_300">#E57373</color>
    <color name="md_red_400">#EF5350</color>
    <color name="md_red_500">#F44336</color>
    <color name="md_red_600">#E53935</color>
    <color name="md_red_700">#D32F2F</color>
    <color name="md_red_800">#C62828</color>
    <color name="md_red_900">#B71C1C</color>
    <color name="md_red_A100">#FF8A80</color>
    <color name="md_red_A200">#FF5252</color>
    <color name="md_red_A400">#FF1744</color>
    <color name="md_red_A700">#D50000</color>

    <!-- pinks -->
    <color name="md_pink_50">#FCE4EC</color>
    <color name="md_pink_100">#F8BBD0</color>
    <color name="md_pink_200">#F48FB1</color>
    <color name="md_pink_300">#F06292</color>
    <color name="md_pink_400">#EC407A</color>
    <color name="md_pink_500">#E91E63</color>
    <color name="md_pink_600">#D81B60</color>
    <color name="md_pink_700">#C2185B</color>
    <color name="md_pink_800">#AD1457</color>
    <color name="md_pink_900">#880E4F</color>
    <color name="md_pink_A100">#FF80AB</color>
    <color name="md_pink_A200">#FF4081</color>
    <color name="md_pink_A400">#F50057</color>
    <color name="md_pink_A700">#C51162</color>

    <!-- purples -->
    <color name="md_purple_50">#F3E5F5</color>
    <color name="md_purple_100">#E1BEE7</color>
    <color name="md_purple_200">#CE93D8</color>
    <color name="md_purple_300">#BA68C8</color>
    <color name="md_purple_400">#AB47BC</color>
    <color name="md_purple_500">#9C27B0</color>
    <color name="md_purple_600">#8E24AA</color>
    <color name="md_purple_700">#7B1FA2</color>
    <color name="md_purple_800">#6A1B9A</color>
    <color name="md_purple_900">#4A148C</color>
    <color name="md_purple_A100">#EA80FC</color>
    <color name="md_purple_A200">#E040FB</color>
    <color name="md_purple_A400">#D500F9</color>
    <color name="md_purple_A700">#AA00FF</color>

    <!-- deep purples -->
    <color name="md_deep_purple_50">#EDE7F6</color>
    <color name="md_deep_purple_100">#D1C4E9</color>
    <color name="md_deep_purple_200">#B39DDB</color>
    <color name="md_deep_purple_300">#9575CD</color>
    <color name="md_deep_purple_400">#7E57C2</color>
    <color name="md_deep_purple_500">#673AB7</color>
    <color name="md_deep_purple_600">#5E35B1</color>
    <color name="md_deep_purple_700">#512DA8</color>
    <color name="md_deep_purple_800">#4527A0</color>
    <color name="md_deep_purple_900">#311B92</color>
    <color name="md_deep_purple_A100">#B388FF</color>
    <color name="md_deep_purple_A200">#7C4DFF</color>
    <color name="md_deep_purple_A400">#651FFF</color>
    <color name="md_deep_purple_A700">#6200EA</color>

    <!-- indigo -->
    <color name="md_indigo_50">#E8EAF6</color>
    <color name="md_indigo_100">#C5CAE9</color>
    <color name="md_indigo_200">#9FA8DA</color>
    <color name="md_indigo_300">#7986CB</color>
    <color name="md_indigo_400">#5C6BC0</color>
    <color name="md_indigo_500">#3F51B5</color>
    <color name="md_indigo_600">#3949AB</color>
    <color name="md_indigo_700">#303F9F</color>
    <color name="md_indigo_800">#283593</color>
    <color name="md_indigo_900">#1A237E</color>
    <color name="md_indigo_A100">#8C9EFF</color>
    <color name="md_indigo_A200">#536DFE</color>
    <color name="md_indigo_A400">#3D5AFE</color>
    <color name="md_indigo_A700">#304FFE</color>

    <!--blue-->
    <color name="md_blue_50">#E3F2FD</color>
    <color name="md_blue_100">#BBDEFB</color>
    <color name="md_blue_200">#90CAF9</color>
    <color name="md_blue_300">#64B5F6</color>
    <color name="md_blue_400">#42A5F5</color>
    <color name="md_blue_500">#2196F3</color>
    <color name="md_blue_600">#1E88E5</color>
    <color name="md_blue_700">#1976D2</color>
    <color name="md_blue_800">#1565C0</color>
    <color name="md_blue_900">#0D47A1</color>
    <color name="md_blue_A100">#82B1FF</color>
    <color name="md_blue_A200">#448AFF</color>
    <color name="md_blue_A400">#2979FF</color>
    <color name="md_blue_A700">#2962FF</color>

    <!-- light blue-->
    <color name="md_light_blue_50">#E1F5FE</color>
    <color name="md_light_blue_100">#B3E5FC</color>
    <color name="md_light_blue_200">#81D4fA</color>
    <color name="md_light_blue_300">#4fC3F7</color>
    <color name="md_light_blue_400">#29B6FC</color>
    <color name="md_light_blue_500">#03A9F4</color>
    <color name="md_light_blue_600">#039BE5</color>
    <color name="md_light_blue_700">#0288D1</color>
    <color name="md_light_blue_800">#0277BD</color>
    <color name="md_light_blue_900">#01579B</color>
    <color name="md_light_blue_A100">#80D8FF</color>
    <color name="md_light_blue_A200">#40C4FF</color>
    <color name="md_light_blue_A400">#00B0FF</color>
    <color name="md_light_blue_A700">#0091EA</color>

    <!-- cyan -->
    <color name="md_cyan_50">#E0F7FA</color>
    <color name="md_cyan_100">#B2EBF2</color>
    <color name="md_cyan_200">#80DEEA</color>
    <color name="md_cyan_300">#4DD0E1</color>
    <color name="md_cyan_400">#26C6DA</color>
    <color name="md_cyan_500">#00BCD4</color>
    <color name="md_cyan_600">#00ACC1</color>
    <color name="md_cyan_700">#0097A7</color>
    <color name="md_cyan_800">#00838F</color>
    <color name="md_cyan_900">#006064</color>
    <color name="md_cyan_A100">#84FFFF</color>
    <color name="md_cyan_A200">#18FFFF</color>
    <color name="md_cyan_A400">#00E5FF</color>
    <color name="md_cyan_A700">#00B8D4</color>

    <!-- teal -->
    <color name="md_teal_50">#E0F2F1</color>
    <color name="md_teal_100">#B2DFDB</color>
    <color name="md_teal_200">#80CBC4</color>
    <color name="md_teal_300">#4DB6AC</color>
    <color name="md_teal_400">#26A69A</color>
    <color name="md_teal_500">#009688</color>
    <color name="md_teal_600">#00897B</color>
    <color name="md_teal_700">#00796B</color>
    <color name="md_teal_800">#00695C</color>
    <color name="md_teal_900">#004D40</color>
    <color name="md_teal_A100">#A7FFEB</color>
    <color name="md_teal_A200">#64FFDA</color>
    <color name="md_teal_A400">#1DE9B6</color>
    <color name="md_teal_A700">#00BFA5</color>

    <!-- green -->
    <color name="md_green_50">#E8F5E9</color>
    <color name="md_green_100">#C8E6C9</color>
    <color name="md_green_200">#A5D6A7</color>
    <color name="md_green_300">#81C784</color>
    <color name="md_green_400">#66BB6A</color>
    <color name="md_green_500">#4CAF50</color>
    <color name="md_green_600">#43A047</color>
    <color name="md_green_700">#388E3C</color>
    <color name="md_green_800">#2E7D32</color>
    <color name="md_green_900">#1B5E20</color>
    <color name="md_green_A100">#B9F6CA</color>
    <color name="md_green_A200">#69F0AE</color>
    <color name="md_green_A400">#00E676</color>
    <color name="md_green_A700">#00C853</color>

    <!--light green-->
    <color name="md_light_green_50">#F1F8E9</color>
    <color name="md_light_green_100">#DCEDC8</color>
    <color name="md_light_green_200">#C5E1A5</color>
    <color name="md_light_green_300">#AED581</color>
    <color name="md_light_green_400">#9CCC65</color>
    <color name="md_light_green_500">#8BC34A</color>
    <color name="md_light_green_600">#7CB342</color>
    <color name="md_light_green_700">#689F38</color>
    <color name="md_light_green_800">#558B2F</color>
    <color name="md_light_green_900">#33691E</color>
    <color name="md_light_green_A100">#CCFF90</color>
    <color name="md_light_green_A200">#B2FF59</color>
    <color name="md_light_green_A400">#76FF03</color>
    <color name="md_light_green_A700">#64DD17</color>

    <!-- lime-->
    <color name="md_lime_50">#F9FBE7</color>
    <color name="md_lime_100">#F0F4C3</color>
    <color name="md_lime_200">#E6EE9C</color>
    <color name="md_lime_300">#DCE775</color>
    <color name="md_lime_400">#D4E157</color>
    <color name="md_lime_500">#CDDC39</color>
    <color name="md_lime_600">#C0CA33</color>
    <color name="md_lime_700">#A4B42B</color>
    <color name="md_lime_800">#9E9D24</color>
    <color name="md_lime_900">#827717</color>
    <color name="md_lime_A100">#F4FF81</color>
    <color name="md_lime_A200">#EEFF41</color>
    <color name="md_lime_A400">#C6FF00</color>
    <color name="md_lime_A700">#AEEA00</color>

    <!--yellow -->
    <color name="md_yellow_50">#FFFDE7</color>
    <color name="md_yellow_100">#FFF9C4</color>
    <color name="md_yellow_200">#FFF590</color>
    <color name="md_yellow_300">#FFF176</color>
    <color name="md_yellow_400">#FFEE58</color>
    <color name="md_yellow_500">#FFEB3B</color>
    <color name="md_yellow_600">#FDD835</color>
    <color name="md_yellow_700">#FBC02D</color>
    <color name="md_yellow_800">#F9A825</color>
    <color name="md_yellow_900">#F57F17</color>
    <color name="md_yellow_A100">#FFFF82</color>
    <color name="md_yellow_A200">#FFFF00</color>
    <color name="md_yellow_A400">#FFEA00</color>
    <color name="md_yellow_A700">#FFD600</color>

    <!--amber-->
    <color name="md_amber_50">#FFF8E1</color>
    <color name="md_amber_100">#FFECB3</color>
    <color name="md_amber_200">#FFE082</color>
    <color name="md_amber_300">#FFD54F</color>
    <color name="md_amber_400">#FFCA28</color>
    <color name="md_amber_500">#FFC107</color>
    <color name="md_amber_600">#FFB300</color>
    <color name="md_amber_700">#FFA000</color>
    <color name="md_amber_800">#FF8F00</color>
    <color name="md_amber_900">#FF6F00</color>
    <color name="md_amber_A100">#FFE57F</color>
    <color name="md_amber_A200">#FFD740</color>
    <color name="md_amber_A400">#FFC400</color>
    <color name="md_amber_A700">#FFAB00</color>

    <!--orange-->
    <color name="md_orange_50">#FFF3E0</color>
    <color name="md_orange_100">#FFE0B2</color>
    <color name="md_orange_200">#FFCC80</color>
    <color name="md_orange_300">#FFB74D</color>
    <color name="md_orange_400">#FFA726</color>
    <color name="md_orange_500">#FF9800</color>
    <color name="md_orange_600">#FB8C00</color>
    <color name="md_orange_700">#F57C00</color>
    <color name="md_orange_800">#EF6C00</color>
    <color name="md_orange_900">#E65100</color>
    <color name="md_orange_A100">#FFD180</color>
    <color name="md_orange_A200">#FFAB40</color>
    <color name="md_orange_A400">#FF9100</color>
    <color name="md_orange_A700">#FF6D00</color>

    <!--deep orange-->
    <color name="md_deep_orange_50">#FBE9A7</color>
    <color name="md_deep_orange_100">#FFCCBC</color>
    <color name="md_deep_orange_200">#FFAB91</color>
    <color name="md_deep_orange_300">#FF8A65</color>
    <color name="md_deep_orange_400">#FF7043</color>
    <color name="md_deep_orange_500">#FF5722</color>
    <color name="md_deep_orange_600">#F4511E</color>
    <color name="md_deep_orange_700">#E64A19</color>
    <color name="md_deep_orange_800">#D84315</color>
    <color name="md_deep_orange_900">#BF360C</color>
    <color name="md_deep_orange_A100">#FF9E80</color>
    <color name="md_deep_orange_A200">#FF6E40</color>
    <color name="md_deep_orange_A400">#FF3D00</color>
    <color name="md_deep_orange_A700">#DD2600</color>

    <!--brown -->
    <color name="md_brown_50">#EFEBE9</color>
    <color name="md_brown_100">#D7CCC8</color>
    <color name="md_brown_200">#BCAAA4</color>
    <color name="md_brown_300">#A1887F</color>
    <color name="md_brown_400">#8D6E63</color>
    <color name="md_brown_500">#795548</color>
    <color name="md_brown_600">#6D4C41</color>
    <color name="md_brown_700">#5D4037</color>
    <color name="md_brown_800">#4E342E</color>
    <color name="md_brown_900">#3E2723</color>

    <!--grey-->
    <color name="md_grey_50">#FAFAFA</color>
    <color name="md_grey_100">#F5F5F5</color>
    <color name="md_grey_200">#EEEEEE</color>
    <color name="md_grey_300">#E0E0E0</color>
    <color name="md_grey_400">#BDBDBD</color>
    <color name="md_grey_500">#9E9E9E</color>
    <color name="md_grey_600">#757575</color>
    <color name="md_grey_700">#616161</color>
    <color name="md_grey_800">#424242</color>
    <color name="md_grey_900">#212121</color>
    <color name="md_black_1000">#000000</color>
    <color name="md_white_1000">#ffffff</color>

    <!--blue grey-->
    <color name="md_blue_grey_50">#ECEFF1</color>
    <color name="md_blue_grey_100">#CFD8DC</color>
    <color name="md_blue_grey_200">#B0BBC5</color>
    <color name="md_blue_grey_300">#90A4AE</color>
    <color name="md_blue_grey_400">#78909C</color>
    <color name="md_blue_grey_500">#607D8B</color>
    <color name="md_blue_grey_600">#546E7A</color>
    <color name="md_blue_grey_700">#455A64</color>
    <color name="md_blue_grey_800">#37474F</color>
    <color name="md_blue_grey_900">#263238</color>

</resources>

Buat file xml diberi nama dimens.xml letakan kode berikut

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="fab_margin">16dp</dimen>
</resources>

Lalu di strings,xml paatekan kode berikut

<resources>
    <string name="app_name">BottomTabNavigation</string>

    <string name="chats_toolbar">FnF Chats</string>
    <string name="contacts_toolbar">FnF Contacts</string>
    <string name="profile_toolbar">FnF Profile</string>

    <string name="drawer_open">Open</string>
    <string name="drawer_close">Close</string>

    <string name="click_action">You Have Clicked</string>
    <string name="something_wrong">Somethings Wrong</string>

</resources>

Pada styles.xml pastekan kode berikut

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
    </style>

    <style name="NavigationDrawerStyle">
        <item name="android:textSize">14sp</item>
        <item name="android:typeface">monospace</item>
    </style>

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@android:color/white</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="colorControlNormal">@android:color/white</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
        <item name="colorControlNormal">@android:color/white</item>
    </style>

    <!--bellow code are not necessary-->

    <style name="Toolbar" parent="ThemeOverlay.AppCompat.ActionBar">
        <!-- android:textColorPrimary is the color of the title text in the Toolbar  -->
        <item name="android:textColorPrimary">@android:color/white</item>
        <!-- actionMenuTextColor is the color of the text of action (menu) items  -->
        <item name="actionMenuTextColor">@android:color/holo_green_light</item>
        <!-- Tints the input fields like checkboxes and text fields -->
        <item name="colorAccent">@android:color/holo_green_light</item>
        <!-- Applies to views in their normal state. -->
        <item name="colorControlNormal">@android:color/holo_green_light</item>
        <!-- Applies to views in their activated state (i.e checked or switches) -->
        <item name="colorControlActivated">@android:color/holo_green_light</item>
        <!-- Applied to framework control highlights (i.e ripples or list selectors) -->
        <item name="colorControlHighlight">@android:color/holo_green_light</item>
    </style>

    <style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
        <item name="android:textSize">14sp</item>
        <item name="android:textStyle">normal</item>
        <item name="android:gravity">center</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:textColor">@android:color/white</item>
    </style>

</resources>

Sekarang beralih ke MainActivity.java,pastekan kode berikut

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import (ganti dengan nama packagename anda).bottom_tab_and_navigation.R;

public class FragmentA extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_a, container, false);
    }


}

Lalu buat java diberi nama FragmentA.java dan pastekan kode berikut

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import (ganti dengan package name).bottom_tab_and_navigation.R;

public class FragmentA extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_a, container, false);
    }


}

Buat sebuah class lagi diberinama FragmentB.java pastekan kode berikut



import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import (ganti dengan package name).bottom_tab_and_navigation.R;

public class FragmentB extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_b, container, false);
    }
}

Buat class lagi diberi nama FragmentC.java dan pastekan kode dibawah ini

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import (ganti dengan package name).bottom_tab_and_navigation.R;


public class FragmentC extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_c, container, false);
    }

}

Nah pada AndroidmManifest.xml pastekan kode berikut dibawah tulisan package

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">
        <activity android:name="anindya.sample.bottom_tab_and_navigation.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Dan kalau ada error pada  layoutnya,terutama pada drawablenya,itu karena kalian belum memasukan file drawablenya,atau bisa di ganti dengan ic_launcher jadi tidak terjasi error,setelah tidak ada eeror coba si run dan semoga beehasil,selanjutnya silahkan sikembangkan lagi.

Baca juga Cara membuat Splash Screen Dengan Android Studio

Semoga bisa sesikit membantu,terima kasih

Hosting Unlimited Indonesia

Need Help? Chat with us
%d bloggers like this: