Skip to content

Instantly share code, notes, and snippets.

@mhrpatel12
Created August 31, 2019 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhrpatel12/7839ca2c75cfe40a5030fd93f6cd1ac6 to your computer and use it in GitHub Desktop.
Save mhrpatel12/7839ca2c75cfe40a5030fd93f6cd1ac6 to your computer and use it in GitHub Desktop.
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
(view?.parent as View).setBackgroundColor(Color.TRANSPARENT)
val resources = resources
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
assert(view != null)
val parent = view?.parent as View
val layoutParams = parent.layoutParams as CoordinatorLayout.LayoutParams
layoutParams.setMargins(
resources.getDimensionPixelSize(R.dimen.screen_margin), // LEFT 16dp
0,
resources.getDimensionPixelSize(R.dimen.screen_margin), // RIGHT 16dp
0
)
parent.layoutParams = layoutParams
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment