materialdesignlibrary

repository·master·Indexed 27 days ago

https://github.com/navasmdc/materialdesignlibrary

A Material Design Android Library providing custom UI components including buttons (ButtonFlat, ButtonRectangle, ButtonFloat), switches, checkboxes, progress indicators, sliders, and widgets such as SnackBar, Dialog, and ColorSelector.

Tokens
3.3K
Snippets
11
Records
11
Agent score
44%

What's inside materialdesignlibrary

  1. Install the Material Design Android Library via Gradle

    master

    To use the library in your Android project, add the following dependency to your build.gradle file. Ensure you have jcenter() in your repositories block.

    repositories {
        jcenter()
    }
    
    dependencies {
        compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
    }
  2. Configure custom attributes in XML layouts

    master

    To use components with custom attributes, you must declare the materialdesign namespace in your XML layout file (e.g., in a RelativeLayout).

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    </RelativeLayout>
  3. Use CustomScrollView to avoid layout issues

    master

    When using a ScrollView, it is recommended to use the CustomScrollView provided by the library to prevent issues with custom components.

    <com.gc.materialdesign.views.ScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.gc.materialdesign.views.ScrollView>
  4. Show a Dialog

    master

    Use the Dialog class to show messages with accept and cancel actions.

    Dialog dialog = new Dialog(Context context, String title, String message);
    dialog.show();
    
    // Set listeners
    dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener);
    dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener);
    
    // Access buttons
    ButtonFlat acceptButton = dialog.getButtonAccept();
    ButtonFlat cancelButton = dialog.getButtonCancel();
    Dialog dialog = new Dialog(Context context,String title, String message);
    dialog.show();
    
    // Set accept click listenner
    dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener);
    // Set cancel click listenner
    dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener);
    // Acces to accept button
    ButtonFlat acceptButton = dialog.getButtonAccept();
    // Acces to cancel button
    ButtonFlat cancelButton = dialog.getButtonCancel();
  5. Use ButtonFloat and ButtonFloatSmall components

    master

    Floating buttons can be used with or without animations and icons.

    • ButtonFloat: Supports materialdesign:animate (boolean) and materialdesign:iconDrawable (drawable).
    • ButtonFloatSmall: A smaller version of the floating button.
    <com.gc.materialdesign.views.ButtonFloat
                    android:id="@+id/buttonFloat"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentBottom="true"
                    android:layout_marginRight="24dp"
                    android:background="#1E88E5"
                    materialdesign:animate="true"
                    materialdesign:iconDrawable="@drawable/ic_action_new" />
    
    <com.gc.materialdesign.views.ButtonFloatSmall
                    android:id="@+id/buttonFloatSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    materialdesign:iconDrawable="@drawable/ic_action_new" />
  6. Use Progress Bar components

    master

    The library provides several progress indicator types:

    • ProgressBarCircularIndeterminate: com.gc.materialdesign.views.ProgressBarCircularIndeterminate
    • ProgressBarIndeterminate: com.gc.materialdesign.views.ProgressBarIndeterminate
    • ProgressBarIndeterminateDeterminate: com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate. Use .setProgress(progress) to update.
    • ProgressBarDeterminate: com.gc.materialdesign.views.ProgressBarDeterminate. Use materialdesign:max and materialdesign:min to set range.
    <com.gc.materialdesign.views.ProgressBarCircularIndeterminate
                    android:id="@+id/progressBarCircularIndeterminate"
                    android:layout_width="32dp"
                    android:layout_height="32dp"
                    android:background="#1E88E5" />
    
    <com.gc.materialdesign.views.ProgressBarIndeterminate
                    android:id="@+id/progressBarIndeterminate"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5" />
    
    <com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate
                    android:id="@+id/progressBarIndeterminateDeterminate"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5" />
    
    <com.gc.materialdesign.views.ProgressBarDeterminate
                    android:id="@+id/progressDeterminate"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5" />
  7. Use ColorSelector

    master

    The ColorSelector widget allows users to select a color from a set.

    ColorSelector colorSelector = new ColorSelector(Context context, int intialColor, OnColorSelectedListener onColorSelectedListener);
    colorSelector.show();
    ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);
    colorSelector.show();
  8. Use CheckBox and Switch components

    master

    Custom Material Design switches and checkboxes:

    • CheckBox: com.gc.materialdesign.views.CheckBox using materialdesign:check (boolean).
    • Switch: com.gc.materialdesign.views.Switch using materialdesign:check (boolean).
    <com.gc.materialdesign.views.CheckBox
                    android:id="@+id/checkBox"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    materialdesign:check="true" />
    
    <com.gc.materialdesign.views.Switch
                    android:id="@+id/switchView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    materialdesign:check="true" />
  9. Use Slider components

    master

    Sliders allow users to select values within a range. You can also enable a number indicator.

    • Slider: com.gc.materialdesign.views.Slider.
    • Attributes: materialdesign:max, materialdesign:min, and materialdesign:showNumberIndicator (boolean).
    <com.gc.materialdesign.views.Slider
                    android:id="@+id/slider"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    materialdesign:max="50"
                    materialdesign:min="0" />
    
    <com.gc.materialdesign.views.Slider
                    android:id="@+id/slider"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    materialdesign:max="50"
                    materialdesign:min="0"
                    materialdesign:showNumberIndicator="true"/>
  10. Use ButtonFlat and ButtonRectangle components

    master

    The library provides two types of flat/rectangle buttons:

    • ButtonFlat: com.gc.materialdesign.views.ButtonFlat
    • ButtonRectangle: com.gc.materialdesign.views.ButtonRectangle
    <com.gc.materialdesign.views.ButtonFlat
                    android:id="@+id/buttonflat"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    android:text="Button" />
    
    <com.gc.materialdesign.views.ButtonRectangle
                    android:id="@+id/button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#1E88E5"
                    android:text="Button" />