Layout margin/padding at the top of dialog fragment

Herr von Wurst picture Herr von Wurst · Aug 27, 2013 · Viewed 15.1k times · Source

When using fragments my layouts get disturbed by an additional space at the top and I don't know where this is coming from. It looks like this:

enter image description here

What are possible sources for this empty space? The theme or some style settings I have not yet found, or is this space reserved for an action bar? I would really like to get rid of this.

Here are the corresponding layout xml and the code to instantiate the dialog:

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_margin="5dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

        <ProgressBar
        android:layout_margin="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/search_progress"
        style="?android:attr/progressBarStyle"
        android:indeterminate="true" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/search_progress"
            android:text="Searching for:" />

        <TextView
            android:id="@+id/searchingNameTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:layout_alignBottom="@+id/search_progress"
            android:layout_alignLeft="@+id/textView1"
            android:text="Barcelona" />

</RelativeLayout>

Java:

FragmentManager fm = this.getSupportFragmentManager();
mSearchingDialog = new SearchingDialogFragment();
Bundle bundle = new Bundle();
bundle.putString("name", mCityToAdd.userName());
mSearchingDialog.setArguments(bundle);
mSearchingDialog.show(fm, TAG);

I also asked this question here, thinking it would be a problem correlated with a scrollview, but the space appears in all my fragments:

ScrollView adds extra space on top

Answer

sergej shafarenka picture sergej shafarenka · Aug 27, 2013

Try to call getWindow().requestFeature(Window.FEATURE_NO_TITLE); right before setContentView(R.layout.<dialog_layout>); in onCreate() or onCreateView() method of your dialog.