I want to create an About dialog.
I’m using “wrap_content” for the height of the dialog and I’m setting the textbox message by
code.
For some reason, the dialog is bigger and there is an empty black space on the top.
The dialog doesn’t fit to the size of my content.
Here is my dialog layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/titleLayout"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="#EBEBEB" >
<ImageView
android:id="@+id/ivAbout"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dunk"
android:layout_marginRight="10dip"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/tvAboutTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#08BCBF"
android:textSize="20sp"
android:paddingRight="10dip"
android:layout_toLeftOf="@+id/ivAboutDunk"
android:layout_centerVertical="true"
android:text="blabla"
/>
</RelativeLayout>
<View
android:id="@+id/lineSeperator"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#08BCBF"
android:layout_below="@+id/titleLayout"
/>
<RelativeLayout
android:id="@+id/aboutStoryLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lineSeperator"
android:background="#FFFFFF" >
<TextView
android:id="@+id/tvAboutStory"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="right"
android:layout_marginRight="12dip"
android:layout_marginTop="10dip"
android:text="bla"
android:textSize="16sp"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/aboutButtonsLayout"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_below="@+id/aboutStoryLayout"
android:background="#BDBDBD" >
<Button
android:id="@+id/dialogButtonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</RelativeLayout>
If you are using that layout to add content to your dialog via dialog.setContentView(View) then I suspect that the black space at the top is the unused title for the dialog. In which case you can hide/remove the title area by using dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)