Skip to content

Edge-to-Edge my support idea(Could not find ucrop-2.2.11.aar???) #963

@yandongletter

Description

@yandongletter

padding can be added to android.R.id.content in the application to solve the problem of third-party libraries not being compatible

private void registerActivityLifecycleCallbacks() {
      registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
          @Override
          public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
              if (activity instanceof PictureSelectorSupporterActivity ||
                      activity instanceof PictureSelectorTransparentActivity ||
                
              ) {
                  //your idea
                  NavigationBarUtil.INSTANCE.applyNavigationBarPadding(activity);
              }
          }
 }

object NavigationBarUtil {

  val SUPPORT_EDGE_TO_EDGE_VERSION = Build.VERSION_CODES.VANILLA_ICE_CREAM//15+
  @JvmField
  val isEdgeToEdgeSupported = Build.VERSION.SDK_INT >= SUPPORT_EDGE_TO_EDGE_VERSION

  /**
   * add padding
   */
  fun applyNavigationBarPadding(activity: Activity) {
      if (isEdgeToEdgeSupported) {
       
          val rootView = activity.window.decorView.findViewById<View>(android.R.id.content)
          if (rootView != null) {
              applyNavigationBarInsets(rootView)
          }
      }
  }


  /**
   * add padding for root view
   */
  fun applyNavigationBarInsets(view: View) {
      val initialPaddingBottom = view.paddingBottom
      ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
          val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
          v.setPadding(
              v.paddingLeft,
              v.paddingTop,
              v.paddingRight,
              initialPaddingBottom + systemBars.bottom
          )
          insets
      }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions