Skip to content
This repository was archived by the owner on Aug 21, 2021. It is now read-only.
Michael Bel edited this page Mar 3, 2018 · 40 revisions
import org.michaelbel.bottomsheet.BottomSheet;
import org.michaelbel.bottomsheet.BottomSheetCallback;
import org.michaelbel.bottomsheet.Utils;
BottomSheet.Builder builder = new BottomSheet.Builder(context);

Set Title

CharSequence, String or StringRes types.

builder.setTitle("My title");
builder.setTitle(R.string.title_text);

Title textView getter:

builder.getTitleTextView().setText("My text");
builder.getTitleTextView().setTextSize(14);

Set Items

Firstly, set the items: (CharSequence, String or StringRes types) like this:

String[] items = new String[] {
    "Share",
    "Upload",
    "Copy",
    "Print this page"
};

CharSequence[] items = new CharSequence[] {
    "Share",
    "Upload",
    "Copy",
    "Print this page"
};

int[] items = new int[] {
    R.string.share,
    R.string.upload,
    R.string.copy,
    R.string.print_this_page
};

Secondly, if you want to use the icons:

int[] icons = new int[] {
    R.drawable.ic_share,
    R.drawable.ic_upload,
    R.drawable.ic_copy,
    R.drawable.ic_print
};

And call the method:

builder.setItems(items, icons, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        // your code here.
    }
});

Set Menu

  1. Create a menu layout file:
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:title="@string/share"
          android:icon="@drawable/ic_share"/>

    <item android:title="@string/upload"
          android:icon="@drawable/ic_upload"/>

    <item android:title="@string/copy"
          android:icon="@drawable/ic_copy"/>

    <item android:title="@string/print_this_page"
          android:icon="@drawable/ic_printer"/>
</menu>
  1. Call the method:
builder.setMenu(R.menu.menu_items, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        // your code here.
    }
});

Set Content type

BottomSheet.LIST or BottomSheet.GRID types. List by default.

builder.setContentType(BottomSheet.LIST);
builder.setContentType(BottomSheet.GRID);

Set Title text color

Examples:

builder.setTitleTextColor(Color.RED);
builder.setTitleTextColor(0xFFFF5252);
builder.setTitleTextColor(getResources().getColor(R.color.my_color));
builder.setTitleTextColor(ContextCompat.getColor(context, R.color.my_color));

Set Items text color

Examples:

builder.setItemTextColor(Color.RED);
builder.setItemTextColor(0xFFFF5252);
builder.setItemTextColor(getResources().getColor(R.color.my_color));
builder.setItemTextColor(ContextCompat.getColor(context, R.color.my_color));

Set Background color

Examples:

builder.setBackgroundColor(Color.RED);
builder.setBackgroundColor(0xFFFF5252);
builder.setBackgroundColor(getResources().getColor(R.color.my_color));
builder.setBackgroundColor(ContextCompat.getColor(context, R.color.my_color));

Set Icons color

Examples:

builder.setIconColor(Color.RED);
builder.setIconColor(0xFFFF5252);
builder.setIconColor(getResources().getColor(R.color.my_color));
builder.setIconColor(ContextCompat.getColor(context, R.color.my_color));

Set Full width

Boolean or BoolRes types.

builder.setFullWidth(true);
builder.setFullWidth(R.bool.full_width);
Full width Default

Set Cell height

Integer type. 48dp default.

builder.setCellHeight(Utils.dp(this, 52);

Set Dividers

Boolean or BoolRes types.

builder.setDividers(true);
builder.setDividers(R.bool.dividers);
Light Dark

Set Title multiline

Boolean or BoolRes types.

builder.setTitleMultiline(true);
builder.setTitleMultiline(R.bool.multiline);

Set Dark theme.

Boolean or BoolRes types.

builder.setDarkTheme(true);
builder.setDarkTheme(R.bool.multiline);

Set Window dimming

Integer type. Range from 0 to 255.

builder.setWindowDimming(100);

Set Callback

BottomSheetCallback type.

builder.setCallback(new BottomSheetCallback() {
    @Override
    public void onShown() {
        // your code here.        
    }

    @Override
    public void onDismissed() {
        // and here.
    }
});

Set View

Coming soon.


Set Items selector

Coming soon.


Set Theme

Coming soon.


Set Dismiss with swipe

Coming soon.


Set Divider color

Coming soon


Show dialog

builder.show();

@Deprecated

setCustomView(...) - Use setView instead.

Clone this wiki locally