use of androidx.coordinatorlayout.widget.CoordinatorLayout in project simperium-android by Simperium.
the class SimperiumBottomSheetDialogFragment method onResume.
@Override
public void onResume() {
super.onResume();
if (getDialog() != null) {
// Limit width of bottom sheet on wide screens; non-zero width defined only for large qualifier.
int dp = (int) getDialog().getContext().getResources().getDimension(R.dimen.width_layout);
if (dp > 0) {
FrameLayout bottomSheetLayout = getDialog().findViewById(com.google.android.material.R.id.design_bottom_sheet);
if (bottomSheetLayout != null) {
ViewParent bottomSheetParent = bottomSheetLayout.getParent();
if (bottomSheetParent instanceof CoordinatorLayout) {
CoordinatorLayout.LayoutParams coordinatorLayoutParams = (CoordinatorLayout.LayoutParams) bottomSheetLayout.getLayoutParams();
coordinatorLayoutParams.width = dp;
bottomSheetLayout.setLayoutParams(coordinatorLayoutParams);
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) bottomSheetParent;
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) coordinatorLayout.getLayoutParams();
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
coordinatorLayout.setLayoutParams(layoutParams);
}
}
}
}
}
Aggregations