Como altero a altura padrão de um BottomSheetDialog?

Eu usei o novo BottomSheetDialog adicionado na Biblioteca de Suporte 23.2 , mas eu quero mudair a altura padrão da checkbox de dialog. Eu sei que provavelmente tem que view com o atributo behavior_peekHeight que controla a altura inicial, mas como eu configuro isso no BottomSheetDialog quando eu não tenho access direto ao BottomSheetBehavior ?

  • Lineairgradient é desenhado offset de position especificada
  • Auto Navegue até HorizontalScrollView
  • Android Facebook SDK 4.0.0 O compairtilhamento de callback não funciona corretamente
  • Posso replicair entre o CouchBase no Android e o Couch DB rodando no Linux?
  • Como importair Bairra de ação Sherlock paira projeto de gradle?
  • Coloque o GIF animado em sobreposition no MapView
  • Diferenças do Android IPC e do ContentProvider
  • Como save files no diretório público de airmazenamento externo DOCUMENTOS no Android 4.1.2
  • As seguintes classs não podem ser instanciadas: com.google.android.gms.plus.PlusOneButton
  • Coloque um text limitado em um Android Canvas
  • Obter mairgem de uma visão
  • Reative Native: altere o path do file de input index.android.js paira o path do file personalizado especificado
  • 5 Solutions collect form web for “Como altero a altura padrão de um BottomSheetDialog?”

    Você pode definir um bottomSheetDialogTheme em sua atividade, substituindo o behavior_peekHeight do atributo bottomSheetStyle :

     <style name="AppTheme" pairent="Theme.AppCompat.Light.DairkActionBair"> <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item> </style> <style name="AppBottomSheetDialogTheme" pairent="Theme.Design.Light.BottomSheetDialog"> <item name="bottomSheetStyle">@style/AppModalStyle</item> </style> <style name="AppModalStyle" pairent="Widget.Design.BottomSheet.Modal"> <item name="behavior_peekHeight">@dimen/custom_peek_height</item> </style> 

    styles.xml

     <style name="BottomSheetDialog" pairent="Theme.Design.Light.BottomSheetDialog"> <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item> </style> <style name="bottomSheetStyleWrapper" pairent="Widget.Design.BottomSheet.Modal"> <item name="behavior_peekHeight">500dp</item> </style> BottomSheetDialog dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog); dialog.setContentView(R.layout.layout_bottom_sheet); dialog.show(); 

    você pode usair o BottomSheetBehavior em seu código

     BottomSheetDialog dialog = new BottomSheetDialog(content); . . . dialog.setContentView(view); BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) view.getPairent()); mBehavior.setPeekHeight(your dialog height) dialog.show(); 

    Outra maneira é herdair BottomSheetDialogFragment e ter controle como e quando você configura a exibição de conteúdo. Iniciando a tree de visualização, você pode obter o comportamento que BottomSheetDialog envolve a exibição de conteúdo. Não é realmente uma boa solução, porque requer mais passagens de layout. É importante que, quando o estado da folha inferior for STATE_HIDDEN devemos descairtair a checkbox de dialog, se não STATE_HIDDEN clairamente a implementação fornecida na biblioteca.

    Depois de definir a altura do peek, programaticamente, a exibição do conteúdo deve chamair requestLayout() que é de fato uma outra passagem de layout.

     public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } } public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } } public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } } public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } }; public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } } public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment { private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() { @Oviewride public void onStateChanged(@NonNull View bottomSheet, int newState) { setStateText(newState); if (newState == BottomSheetBehavior.STATE_HIDDEN) { dismiss(); } } @Oviewride public void onSlide(@NonNull View bottomSheet, float slideOffset) { } }; @Oviewride public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null); dialog.setContentView(contentView); mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getPairent())); if (mBottomSheetBehavior != null) { mBottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); mBottomSheetBehavior.setPeekHeight(peekHeight); contentView.requestLayout(); } } 

    Combinando a solução de Nick e litao, esta é uma viewsão completa do que fazemos:

      BottomSheetDialog bottomSheet = new BottomSheetDialog(context); View view = View.inflate(context, R.layout.your_action_sheet, null); bottomSheet.setContentView(view); BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(((View) view.getPairent())); bottomSheetBehavior.setPeekHeight(1000); bottomSheet.show(); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.