All of the other answers here makes sense, but it did not meet what Fabian needs. Here is a solution of mine. It may not be the perfect solution but it works for me. It shows a dialog which is on fullscreen but you can specify a padding on top, bottom, left or right.
First put this in your res/values/styles.xml :
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/Black0Percent</item>
<item name="android:paddingTop">20dp</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsFloating">false</item>
</style>
As you can see I have there android:paddingTop= 20dp is basically what you need. The android:windowBackground = @color/Black0Percent is just a color code declared on my color.xml
res/values/color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="Black0Percent">#00000000</color>
</resources>
That Color code just serves as a dummy to replace the default window background of the Dialog with a 0% transparency color.
Next build the custom dialog layout res/layout/dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialoglayout"
android:layout_width="match_parent"
android:background="@drawable/DesiredImageBackground"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/edittext1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="18dp" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dummy Button"
android:textSize="18dp" />
</LinearLayout>
Finally here is our dialog that set custom view which uses our dialog.xml:
Dialog customDialog;
LayoutInflater inflater = (LayoutInflater) getLayoutInflater();
View customView = inflater.inflate(R.layout.dialog, null);
// Build the dialog
customDialog = new Dialog(this, R.style.CustomDialog);
customDialog.setContentView(customView);
customDialog.show();
Conclusion: I tried to override the dialog's theme in the styles.xml named CustomDialog. It overrides the Dialog window layout and gives me the chance to set a padding and change the opacity of the background. It may not be the perfect solution but I hope it helps you..:)