2017-08-03 89 views
0

我想使用圖像作爲我的加載對話框的背景。對話應該是全屏的,但我得到的是這樣的......全屏加載對話框將不會完全全屏

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); 
+0

這就是對話框片段的行爲,但是你可以覆蓋它通過https://stackoverflow.com/a/25623185/2700586 – Mani

+0

@Mani我不能讓它與視圖工作。我編輯我的問題,以顯示Java代碼 –

+0

發佈代碼如何顯示spinnerdialog – Mani

回答

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

添加上面的代碼SpinnerDialog類裏面!

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); 
} 
+0

不能在我的班級上班。我將java代碼添加到問題中 –