Skip to content

Getting started

Davide Giuseppe Farella edited this page Mar 13, 2019 · 1 revision

Layout ( minimal )

First you need to use a MaterialBottomDrawerLayout as parent of MaterialBottomAppBar.

<studio.forface.materialbottombar.layout.MaterialBottomDrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawerLayout"   	    
    android:layout_width="match_parent"    
    android:layout_height="match_parent">
	
	<!-- Here it goes your content -->
    
    <studio.forface.materialbottombar.appbar.MaterialBottomAppBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"/>
	    
</studio.forface.materialbottombar.layout.MaterialBottomDrawerLayout>

Drawer ( minimal )

with DSL
drawerLayout.drawer = drawer {
    header {
        iconUrl = IMAGE_URL
        titleText = "My drawer"
    }
    body {
        onItemClick = { id, title -> /* do something */ }
        primaryItem( "Messages" ) {
            id = 1
            iconResource = R.drawable.ic_message_black_24dp
        }
        primaryItem( contactsSpannable ) {
            id = 2
            iconDrawable = contactsDrawable
        }
        divider()
        primaryItem( R.string.settings_drawer_title ) {
            id = 3
            iconBitmap = settingsBitmap
        }
    }
}

without DSL:

val header = MaterialDrawer.Header()
    .iconUrl( IMAGE_URL )
    .titleText( "My drawer" )
	    
val messages = PrimaryDrawerItem()
    .id( 1 )	
    .titeText( "messages" )
    .iconResource( R.drawable.ic_message_black_24dp )

val contacts = PrimaryDrawerItem()
    .id( 2 )
    .titleSpannable( contactsSpannable )
    .iconDrawable( contactsDrawable )

val settings = PrimaryDrawerItem()
    .id( 3 )
    .titleRes( R.string.settings_drawer_title )
    .iconBitmap( settingsBitmap )

val body = MaterialDrawer.Body()
    .itemClikListener { id, title -> /* do something */ }
    .items( listOf(
        messages,
        contacts,
        Divider(),
        settings
    ) ) 

drawerLayout.drawer = MaterialDrawer( header, body )
Clone this wiki locally