Skip to content

Instantly share code, notes, and snippets.

@Vnicius
Created September 22, 2021 19:44
Show Gist options
  • Save Vnicius/21f1ff358b85696a7729348d06245c04 to your computer and use it in GitHub Desktop.
Save Vnicius/21f1ff358b85696a7729348d06245c04 to your computer and use it in GitHub Desktop.
Example of DialogFragment with fixed width
<style name="AlertDialogStyle" parent="Theme.AppCompat.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowMinWidthMajor">500dp</item>
<item name="android:windowMinWidthMinor">90%</item>
</style>
open class TransparentBackgroundDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
setStyle(STYLE_NO_TITLE, R.style.AlertDialogStyle)
return super.onCreateDialog(savedInstanceState)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment