本文整理匯總了Java中android.support.design.widget.BottomSheetBehavior.setPeekHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java BottomSheetBehavior.setPeekHeight方法的具體用法?Java BottomSheetBehavior.setPeekHeight怎麽用?Java BottomSheetBehavior.setPeekHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.BottomSheetBehavior
的用法示例。
在下文中一共展示了BottomSheetBehavior.setPeekHeight方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateDialog
import android.support.design.widget.BottomSheetBehavior; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_recycler, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setPeekHeight(ScreenUtil.dip2px(getContext(), PEEK_HEIGHT));
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
mToolbar.setNavigationOnClickListener(this);
onPostCreate(this);
return mSheet;
}
示例2: onCreateDialog
import android.support.design.widget.BottomSheetBehavior; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_recycler, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setPeekHeight(ScreenUtil.dip2px(getContext(), PEEK_HEIGHT));
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
mToolbar.setNavigationOnClickListener(this);
mToolbar.inflateMenu(R.menu.menu_generic_detail);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(getContext(), "Showing your current favour state", Toast.LENGTH_SHORT).show();
return true;
}
});
mFavourite = mToolbar.getMenu().findItem(R.id.action_favor_state);
onPostCreate(this);
return mSheet;
}
示例3: setupDialog
import android.support.design.widget.BottomSheetBehavior; //導入方法依賴的package包/類
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
Bundle bundle = getArguments();
pos = bundle.getInt("pos");
bean = (AppBean) bundle.getSerializable("bean");
contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null);
dialog.setContentView(contentView);
((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel());
if (bean.isMark()) {
contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE);
contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this);
contentView.findViewById(R.id.view_hint_undo_mark)
.setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE);
} else {
contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE);
contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this);
contentView.findViewById(R.id.view_hint_mark)
.setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE);
}
contentView.findViewById(R.id.view_hint_lost)
.setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE);
contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this);
contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior
.from((View) contentView.getParent());
if (bean.isHintLost()) {
// In landscape, STATE_EXPANDED doesn't make sheet expanded.
// Maybe it's a bug. So do this to fix it.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
contentView.measure(0, 0);
bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
}
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
} else {
bottomSheetBehavior.setPeekHeight(getResources()
.getDimensionPixelSize(R.dimen.req_bottom_menu_height));
}
}
示例4: show
import android.support.design.widget.BottomSheetBehavior; //導入方法依賴的package包/類
@Override
public void show() {
if (getContext().getResources().getBoolean(R.bool.is_tablet)) {
final int peekHeight = getContext().getResources().getDimensionPixelSize(R.dimen.tablet_bottom_sheet_peekheight);
BottomSheetBehavior<View> bsBehaviour = BottomSheetBehavior.from((View) contentView.getParent());
bsBehaviour.setPeekHeight(peekHeight);
}
super.show();
}
示例5: getDefaultBottomSheetBehaviour
import android.support.design.widget.BottomSheetBehavior; //導入方法依賴的package包/類
private BottomSheetBehavior getDefaultBottomSheetBehaviour(View bottomSheetView) {
BottomSheetBehavior behavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels/3);
return behavior;
}