Welcome to

w3study.github.io




Topics

Introduction to Meterial Design

Navigation

Floating Button

Tool Bar



Material Design in Android (Introduction, Navigation, Floating Button, Tool Bar) in Hindi

Introduction to Material Design

Key Features of Material Design:

Key Features of Navigation in Material Design:

Example of Navigation Drawer

Step 1: Add Dependencies in build.gradle

gradle

implementation 'com.google.android.material:material:1.4.0'

Step 2: Add Navigation Drawer in XML

xml

<com.google.android.material.navigation.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:menu="@menu/nav_menu"/>

Step 3: Handle Navigation in Java

java

drawerLayout = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(item -> {
    if (item.getItemId() == R.id.nav_home) {
        Toast.makeText(this, "Home Selected", Toast.LENGTH_SHORT).show();
    }
    drawerLayout.closeDrawer(GravityCompat.START);
    return true;
});

Floating Button/Floating Action Button (FAB)

Key Features of FAB:

Example of Floating Action Button

Step 1: Add Floating Action Button in XML

xml

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_add"
    app:backgroundTint="@color/purple_500"/>

Step 2: Set Click Event in Java

java

FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(view -> 
    Toast.makeText(this, "FAB Clicked!", Toast.LENGTH_SHORT).show()
);

ToolBar in Material Design

Key Features of Toolbar:

Example of Toolbar in Android

Step 1: Add Toolbar in XML

xml

<androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:title="My App"
    app:navigationIcon="@drawable/ic_menu"/>

Step 2: Set Toolbar in Java

java

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(view -> 
    Toast.makeText(this, "Navigation Clicked!", Toast.LENGTH_SHORT).show()
);


  • Development of Android Applications Notes in Hindi


  • Request:

    हैलो दोस्तों! उम्मीद करता हूं आपको हमारा यह content/post पसंद आया होगा। अगर आपको हमारा ये content/post पसंद आई हो तो अपने दोस्तों के पास भी share करे। और अगर आपको कोई problem या कोई specific content हिन्दी में चाहिए है तो आप हमें नीचे दिए गए Email या whatsapp number के जरिए बता सकते है।

    अगर आप CCC/diploma/polytechnic/MCA/BCA etc कर रहे है तो ये website स्पेशली आपके लिए ही है, जो student हिंदी में पढ़ाई करते है।

    Contact Us

    Email: deepanshuranjan8057@gmail.com

    Whatsapp: +91 8057754706



    Follow Us

    Facebook Logo    Instagram Logo