Skip to content
This repository was archived by the owner on Aug 21, 2021. It is now read-only.
Michael Bel edited this page Feb 27, 2018 · 40 revisions

Menu


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 Resurce Int types.

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

And title textView getter:

builder.getTitleTextView().setText("Any my text");
builder.getTitleTextView().setLinex(2);

Set Items

Firstly, set the items: (CharSequence, String or Resurce int) 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_printer
};

And call the method:

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

Set CustomView

Coming soon.


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 Items selector

Coming soon.


Set Full width

Boolean or BoolRes types.

builder.setFullWidth(true);
builder.setFullWidth(R.bool.full_width);
Full width By default
image1 image2

Set Cell height

Int value. 48dp by default.

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

Set Dividers

Boolean or BoolRes int types.

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

Set Divider color

Coming soon


Set Title multiline

Boolean or BoolRes int types.

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

Set Dark theme.

Boolean or BoolRes int types.

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

Set Theme

Coming soon.


Set Window dimming

Int value 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.
    }
});

Show

And the last call

builder.show();
Clone this wiki locally