简体   繁体   English

DialogFragment顶部的白色矩形

[英]White rectangle on top of DialogFragment

When using a dialogFragment I get a white space rectangle at the top of the fragment without knowing why. 当使用dialogFragment时,我在片段的顶部得到一个空白矩形,却不知道为什么。

What I should get 我应该得到什么 在此处输入图片说明

What I actually get 我实际上得到了什么 在此处输入图片说明

My DialogFragment: 我的DialogFragment:

 public class SelectDialogFragment extends DialogFragment {

            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            //inflate layout with recycler view
            View v = inflater.inflate(R.layout.select_frag, container, false);
            return v;
        }

}

select_frag.xml select_frag.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:orientation="vertical"
    android:background="#000"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="New Text"
        android:id="@+id/textView" />
</RelativeLayout>

You should set style without title: 您应该设置没有标题的样式:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(STYLE_NO_TITLE, 0);
}

Also you can found more useful example here 您也可以在这里找到更多有用的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM