BottomSheetDialog底部按钮
2017-07-06 00:00
495 查看
http://www.jianshu.com/u/35167a70aa39
解决状态栏变色
http://blog.csdn.net/aiynmimi/article/details/66969109
private void showShareDialog(){ if(mBottomSheetDialog == null){ mBottomSheetDialog = new MyBottomSheetDialog(getActivity()); View v=LayoutInflater.from(getActivity()).inflate(R.layout.bottom_sheet_share_dialog,null); mBottomSheetDialog.setContentView(v); mBottomSheetDialog.setCancelable(true); mBottomSheetDialog.setCanceledOnTouchOutside(true); //点击事件 SuperTextView add=V.findViewById(v,R.id.add_menu); SuperTextView cancel=V.findViewById(v,R.id.cancel_menu); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(), "add", Toast.LENGTH_SHORT).show(); mBottomSheetDialog.dismiss(); } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mBottomSheetDialog.dismiss(); } }); // 解决下滑隐藏dialog 后,再次调用show 方法显示时,不能弹出Dialog final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(mBottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet)); bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { if (newState == BottomSheetBehavior.STATE_HIDDEN) { Log.i("BottomSheet","onStateChanged"); mBottomSheetDialog.dismiss(); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }); }else{ mBottomSheetDialog.show(); } }
解决状态栏变色
http://blog.csdn.net/aiynmimi/article/details/66969109
public class MyBottomSheetDialog extends BottomSheetDialog { private Context context; public MyBottomSheetDialog(@NonNull Context context) { super(context); this.context=context; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int screenHeight = getScreenHeight((Activity) context); int statusBarHeight = getStatusBarHeight(getContext()); int dialogHeight = screenHeight - statusBarHeight; getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, dialogHeight == 0 ? ViewGroup.LayoutParams.MATCH_PARENT : dialogHeight); } private static int getScreenHeight(Activity activity) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); return displaymetrics.heightPixels; } private static int getStatusBarHeight(Context context) { int statusBarHeight = 0; Resources res = context.getResources(); int resourceId = res.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { statusBarHeight = res.getDimensionPixelSize(resourceId); } return statusBarHeight; } }
相关文章推荐
- Android 6.0新控件 BottomSheetDialog | 底部对话框 介绍及使用详情
- BottomSheetDialog底部弹出框、butterkoife使用
- 使用 DialogFragment 和 BottomSheet 实现底部弹出框
- Android底部对话框的实现(BottomSheet,自定义Dialog)
- Android使用BottomSheetBehavior 和 BottomSheetDialog实现底部弹窗
- Android BottomSheetDialog实现底部对话框的示例
- 【Android】BottomSheetDialog详解
- 开源项目:底部动作条(BottomSheet)
- BottomSheetDialog的简单实用
- Material Design系列,Behavior之BottomSheetBehavior与BottomSheetDialog
- 如何禁止使用bottomsheetdialogfragment拖动?
- BottomSheetDialog的使用
- BottomSheetDialog小优化
- Android BottomSheet:便捷易用的底部滑出面板(1)
- 解决使用BottomSheetDialog时状态栏变黑的问题
- 解决使用BottomSheetDialog时状态栏变黑的问题
- 底部切换按钮LuseenBottomNavigation
- Android 分享界面,使用BottomSheetDialog(可上拉到顶部,可下拉消失,仿知乎、掘金等)
- Android 关于BottomDialogSheet 与Layout擦出爱的火花?
- BottomSheetBehavior底部弹出的用法