chosenOne Thabs
chosenOne Thabs

Reputation: 1640

Xamarin - How can i remove extra space at the top of dialogfragment

I have created a dialog fragment in Xamarin. My only issue is that this fragment shows a grey part on it. And i can't figure out what causes the grey part to appear. Do you guys perhaps know the possible cause ?

enter image description here

I'm using this code to display this dialog :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
     android:focusableInTouchMode="true">
  <View
      android:id="@+id/makedialogfullscreenChooseSoundTrack"
      android:layout_width="wrap_content"
      android:layout_height="1dp"
      android:layout_gravity="fill_horizontal"
       />

  <RelativeLayout
       android:orientation="horizontal"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="#e1effa" >
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Choose Sound Track"
        android:textSize="20dp"
        android:textColor="#673ab7"
        android:padding="15dp"
        android:layout_marginRight="25dp"
      />
    <ImageView
        android:id="@+id/imgCloseSoundDialog"
        android:layout_width="33dp"
        android:layout_height="33dp"
        android:src="@drawable/close_icon"
        android:layout_marginBottom="15.5dp"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:layout_centerVertical="true" />
  </RelativeLayout>

  <LinearLayout
      android:orientation="vertical"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"  >
    <GridView
               android:id="@+id/gvSoundFiles"
               android:layout_width="fill_parent"
               android:layout_height="400dp"
               android:gravity="center"
               android:verticalSpacing="5dp"
               android:drawSelectorOnTop="true"
               android:stretchMode="columnWidth" />

  </LinearLayout>
</LinearLayout>

Upvotes: 2

Views: 260

Answers (2)

chosenOne Thabs
chosenOne Thabs

Reputation: 1640

I solved the issue by adding this line in OnCreateView(..) method :

Dialog.Window.RequestFeature(WindowFeatures.NoTitle);

Upvotes: 2

RafaelFerreira
RafaelFerreira

Reputation: 125

by default the DialogFragment comes with a theme with a title bar, to solve this put the code below in the constructor

SetStyle(DialogFragmentStyle.NoTitle, 0);

Upvotes: 1

Related Questions