I am trying to create a DialoFragment with an AppCompat theme, but when I use the AppCompat theme, the dialog title is not displayed.
I use a specific style:
<style name="DialogFragment" parent="Theme.AppCompat.Light.Dialog"/>
When the parent theme is changed to:
<style name="DialogFragment" parent="android:Theme.Material.Light.Dialog"/>
or
<style name="DialogFragment" parent="android:Theme.Holo.Light.Dialog"/>
Headline
displayed correctly.
Code of my dialogue:
public class InfoDialog extends DialogFragment { public static final String TAG = InfoDialog.class.getName(); @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.getWindow().setTitle(getString(R.string.dialog_title)); return dialog; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragment); } @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.info_dialog, container, false); } }
Any ideas what causes the problem? Using the com.android.support:appcompat-v7:22.2.0 application, maybe this is a platform error?
android android-dialogfragment appcompat
Wilek
source share