Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout margin/padding at the top of dialog fragment

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

like image 949
Herr von Wurst Avatar asked Aug 27 '13 12:08

Herr von Wurst


People also ask

What is layout padding?

Padding is the space inside the border, between the border and the actual view's content. Note that padding goes completely around the content: there is padding on the top, bottom, right and left sides (which can be independent).

What is padding in Android layout?

Padding can be used to offset the content of the view by a specific number of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge.

What is margin in Android Studio?

Margin specifies an extra space outside that View on which we applied Margin. In simple words, Margin means to push outside. Diagrammatically, the margin is shown below: Syntax: android:layout_margin=”size in dp”


1 Answers

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

like image 105
sergej shafarenka Avatar answered Sep 18 '22 13:09

sergej shafarenka