全屏加载对话框未完全全屏显示

时间:2017-08-03 01:02:32

标签: android xml android-layout

我正在尝试使用图像作为加载对话框的背景。该对话框应该是全屏的,但我得到的只是这个......

Dialog Example

如何让对话框填满屏幕,以便我没有白色边框?

继承我的布局xml ......

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/locating"
    >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="@drawable/kumalocating">
        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="LOCATING OFFERS IN YOUR AREA"
            android:textAlignment="center"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            android:textColor="@android:color/white"
            android:textSize="30sp"
            android:textStyle="bold" />
    </RelativeLayout>

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_marginTop="10dp"
        android:layout_gravity="center"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:indeterminateDrawable="@drawable/loader_1" />
</RelativeLayout>

和我的班级......

public class SpinnerDialog extends DialogFragment {

    private static String message;

    public SpinnerDialog() {
        // use empty constructors. If something is needed use onCreate's
        message = null;
    }

    public static SpinnerDialog spinnerWithCustomMessage(String msg) {
        SpinnerDialog d = new SpinnerDialog();
        message = msg;

        return d;
    }

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

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
}

显示的代码:

    spinnerDialog = SpinnerDialog.spinnerWithCustomMessage(getString(R.string.lo‌​ading_message)); 
spinnerDialog.show(getFragmentManager(), null);

2 个答案:

答案 0 :(得分:1)

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
}

在SpinnerDialog类中添加上面的代码!

答案 1 :(得分:0)

在Java类中使用此代码。

 Dialog mydialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);

修改

在SpinnerDialog中添加以下行。

 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setStyle(STYLE_NO_FRAME, android.R.style.Theme_Translucent_NoTitleBar);
 }