DialogFragment уходит за пределы экрана
При отображении всплывающее окно не показывается, экран затемняется и все. Пробовал подключить другую разметку - отображается нормально.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".nacartu.InfoActivity">
<com.google.android.material.card.MaterialCardView
android:id="@+id/offerCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="30dp"
app:cardElevation="5dp"
app:cardUseCompatPadding="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/descriptionInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:autoLink="web"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/okBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:backgroundTint="@color/background"
android:text="Закрыть"
android:textColor="#f0f0f0"
app:cornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/descriptionInfo" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
public class InfoActivity extends DialogFragment {
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_info, container, false);
String desc = CreditApplication.getInstance().getDb().getLicense_term();
TextView infoTxt = root.findViewById(R.id.descriptionInfo);
infoTxt.setText(Html.fromHtml(desc));
DialogFragment df = this;
MaterialButton okBtn = root.findViewById(R.id.okBtn);
okBtn.setOnClickListener(v -> { df.getDialog().cancel(); });
if (getDialog() != null && getDialog().getWindow() != null) {
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
return root;
}
}
InfoActivity infoActivity = new InfoActivity();
infoActivity.show(getSupportFragmentManager(), "Info");