I\'ve trying to create DialoFragment with AppCompat theme, but when i use AppCompat theme, dialog title is not shown.
I\'am using defined style:
Theme.AppCompat.Light.Dialog
sets no title window in default.
Try something like below:
<style name="DialogFragment" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">false</item>
</style>
As far as i know once you override onCreateView you are overriding the default layout of the dialogFragment. so i suggest that you create the whole custom dialog fragment layout.
here's a sample xml layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_dialog"
android:orientation="vertical"
android:padding="@dimen/margin_standard">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/margin_standard"
>
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/dialog_error_prompt_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lorem"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/margin_standard"
android:layout_marginLeft="@dimen/horizontal_margin"
android:layout_marginRight="@dimen/margin_standard"
android:layout_marginTop="@dimen/margin_standard"
>
<TextView
android:id="@+id/dialog_error_prompt_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lorem_long"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal"
android:weightSum="1"
android:padding="@dimen/margin_standard">
<TextView
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/margin_standard"
android:clickable="true"
android:padding="@dimen/margin_standard"
android:text="@string/cancel"
android:textAppearance="?android:attr/textAppearanceButton"
android:layout_weight=".70"
android:gravity="center"
android:textColor="@color/primary"/>
<TextView
android:gravity="center"
android:layout_weight=".30"
android:id="@+id/dialog_error_prompt_positive_button"
android:layout_width="wrap_content"
android:layout_height="@dimen/standard_button_height"
android:layout_margin="@dimen/margin_standard"
android:background="@drawable/primary_button_selector_background"
android:clickable="true"
android:padding="@dimen/margin_standard"
android:text="@string/ok"`enter code here`
android:textAppearance="?android:attr/textAppearanceButton"
android:textColor="@color/background_floating_material_light"/>
</LinearLayout>
</LinearLayout>
Try extending AppCompatDialogFragment instead of DialogFragment. That should do the trick.