Using AppCompatDialog Removes titles from the Dialog

903 Views Asked by At

Once I switched from ActionBarActivity to AppCompatActivity one of the only changes I did was add this line:

 <item name="windowNoTitle">true</item>

Here is my entire styles.xml file:

<style name="gptheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="ThemeNoActionBar" parent="gptheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Now, all the new AppCompatDialogs in my code, (which were formerly Dialog d = new Dialog(mContext), all have no titles even though I use setTitle().

Obviously the change I made to the titles specified windowNoTitle but that should only affect the parent activity. I would think, anyway.

How exactly does this new feature work?

1

There are 1 best solutions below

0
On

// style.xml

<style name="DialogActivity" parent="Theme.AppCompat.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="colorAccent">#fff</item>
</style>

// manifest.xml

<activity
  android:name=".MyPopupActivity"
  android:theme="@style/DialogActivity"/>

// activity

import android.app.Activity;
public class MyPopupActivity extends Activity
{
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_popup);
  }
}