显示对话框片段不正确

时间:2019-12-20 15:55:18

标签: android-dialogfragment android-studio-3.0

在我的活动中:

@Override
    public void showProgressDialog() {
        dialogFragment = new ProgressDialogFragment();
        dialogFragment.setCancelable(false);
        dialogFragment.show(getSupportFragmentManager(), "tag");
    }

这是我的对话框片段

import android.support.v4.app.DialogFragment;

public class ProgressDialogFragment extends DialogFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.progress_dialog_fragment, null);
    }

此处xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="64dp">

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/margin_default"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/titleTextView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/margin_default"
        android:text="@string/awaiting_client_confirmation"
        android:textColor="@android:color/black"
        android:textSize="17sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/progressBar"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

}

结果如下:

enter image description here

您可以看到它在整个屏幕上显示。但我为此设置了高度:

android:layout_height="64dp"

我想显示 64dp 的高度。 也不会显示titleTextView

0 个答案:

没有答案
相关问题