Empty space when creating an AlertDialog, only in Oppo phones

I was just trying to migrate my application from a Realme to an Oppo and everything looked fine until I noticed the displayed dialogs were not centered. Here is the example (I will only talk about the loading dialog but is a common problem to all dialogs):
Not centered dialog

My code for creating the Dialog is:

public class GenericAlert extends DialogFragment {

    public static final int LOADING_ALERT = 0;
    public static final int SENDING_ALERT = 1;
    public static final int ERROR_ALERT = 2;

    private int alertType;

    private boolean showing = false;

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        int layoutToSet;
        switch (alertType) {
            case LOADING_ALERT: layoutToSet = R.layout.loading_alert_layout; break;
            case SENDING_ALERT: layoutToSet = R.layout.sending_alert_layout; break;
            case ERROR_ALERT: layoutToSet = R.layout.error_alert_layout; break;
            default: layoutToSet = R.layout.error_alert_layout; break;
        }


        View loadingAlertLayout = getLayoutInflater().inflate(layoutToSet, null);
        builder.setView(loadingAlertLayout);

        if (alertType == SENDING_ALERT) {
            builder.setCancelable(false);
        }

        AlertDialog alert = builder.create();
        alert.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        return alert;
    }
    ...
}

I disabled the transparent background to see how much space was the dialog using: Not centered dialog with white background

Here is my XML file loading_alert_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/less_round_corners_white_borders"
    android:padding="10dp">
    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical">
        <pl.droidsonroids.gif.GifImageView
            android:layout_weight=".3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:src="@drawable/loading_animation"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:adjustViewBounds="true"
            android:padding="10dp"/>
        <androidx.appcompat.widget.AppCompatTextView
            android:layout_weight=".7"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:text="Cargando"
            android:textSize="32sp"
            android:textColor="#000"
            android:gravity="center_vertical|start"
            android:paddingStart="10dp"/>
    </androidx.appcompat.widget.LinearLayoutCompat>
    <androidx.appcompat.widget.AppCompatTextView
        android:paddingHorizontal="10dp"
        android:textColor="#000"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:layout_marginTop="10dp"
        android:text="Se están recibiendo los datos, por favor, espere."/>
</androidx.appcompat.widget.LinearLayoutCompat>

I’m using both physical phones to test my app and I want to get rid of that annoying space.

I’ve tried almost everything that goes through my mind, with no luck, such as setting LayoutParams when inflating the View, requesting the FEATURE_NO_TITLE, changing the root view from a linear layout to a relative layout, constraint layout, and so on, and nothing seems to help me delete that empty space, that only occurs on the Oppo phone, not my Realme phone.

Note: When changing the root view, I’ve noticed the spacing does change when using differents views, here are some results I’ve got with views with just 10 dp padding, a red background, and match_parent and wrap_content values for layout_width and layout_height respectively:
LinearLayoutCompat, ConstraintLayout, AppCompatTextView, AppCompatButton

Seriously, I have no clue why this is happening and I’ve run out of ideas. Also, this is my first question here on StackOverflow, so be free to point out any mistakes I’ve made in my writing.

New contributor

DeadFrancis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật