Search in sources :

Example 11 with CoordinatorLayout

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);
                }
            }
        }
    }
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) ViewParent(android.view.ViewParent) FrameLayout(android.widget.FrameLayout)

Aggregations

CoordinatorLayout (androidx.coordinatorlayout.widget.CoordinatorLayout)11 View (android.view.View)4 FrameLayout (android.widget.FrameLayout)4 Options (com.reactnativenavigation.options.Options)3 ChildControllersRegistry (com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry)3 ViewGroup (android.view.ViewGroup)2 ViewParent (android.view.ViewParent)2 SimpleViewController (com.reactnativenavigation.mocks.SimpleViewController)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 SharedPreferences (android.content.SharedPreferences)1 SpannableString (android.text.SpannableString)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 LayoutInflater (android.view.LayoutInflater)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 AppBarLayout (com.google.android.material.appbar.AppBarLayout)1