当使用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
<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>
答案 0 :(得分:6)
您应该设置没有标题的样式:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, 0);
}
您还可以找到更有用的示例here