0

Если использую всё работает setContentView(R.layout.fragment_purchase_premium)
Если использую не работает setContentView(binding.root) layout перестаёт реагировать на указанные атрибуты margin
Вопрос как изменить AlertDialog background работая с binding и чтобы layout атрибуты margin реагировали на устанновленые значения

class PremiumPurchaseDialog(context: Context) : AlertDialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = FragmentPurchasePremiumBinding.inflate(layoutInflater)
        setContentView(binding.root)
        //не помогает
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        //не помогает
        window?.decorView?.setBackgroundColor(Color.TRANSPARENT)
    }
}

Пробовал использовать AlertDialog(context, R.style.CustomDialog) не помогает

<style name="CustomDialog" parent="android:Theme.Dialog">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">@android:color/transparent</item>
</style>

1 ответ 1

0

Может вам использовать DialogFragment? Когда я использую его, прозрачный фон и отступы работают. Ну и несомненный плюс DialogFragment - при смене ориентации он не убивается.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.