This repository was archived by the owner on Aug 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Usage
Michael Bel edited this page Feb 27, 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);
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);
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.
}
});
Coming soon.
BottomSheet.LIST or BottomSheet.GRID types. List by default.
builder.setContentType(BottomSheet.LIST);
builder.setContentType(BottomSheet.GRID);
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));
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));
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));
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));
Coming soon.
Boolean or BoolRes int types.
builder.setFullWidth(true);
builder.setFullWidth(R.bool.full_width);
With Full width | By default |
---|---|
![]() |
![]() |
Int value. 48dp by default.
builder.setCellHeight(Utils.dp(this, 52);
Boolean or BoolRes int types.
builder.setDividers(true);
builder.setDividers(R.bool.dividers);
Coming soon
Boolean or BoolRes int types.
builder.setTitleMultiline(true);
builder.setTitleMultiline(R.bool.multiline);
Boolean or BoolRes int types.
builder.setDarkTheme(true);
builder.setDarkTheme(R.bool.multiline);
Coming soon.
Int value range from 0 to 255.
builder.setWindowDimming(100);
BottomSheetCallback type.
builder.setCallback(new BottomSheetCallback() {
@Override
public void onShown() {
// your code here.
}
@Override
public void onDismissed() {
// and here.
}
});
And the last call
builder.show();