Action bar looks cut while using Theme.AppCompat.Dialog

android, android-actionbar, dialog, styles, themes

Solution

First, when I encountered this problem, I tried using `supportRequestWindowFeature(Window.FEATURE_NO_TITLE);` but this didn't work for me and had no effect.

The alternative method to remove the bar at the top of your dialog activity would be to create a custom style and apply it to that activity.

In `styles.xml`, create a new style like so:

<style name="MyCustomDialog" parent="Base.Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

Now, in `AndroidManifest.xml`, add in `android:theme="@style/MyCustomDialog"` to your activity.

Of course, `MyCustomDialog` can be renamed to anything you want.

Problem

I wished to make one of my activities to look like a dialog and used a Theme.AppCompat.Dialog theme for it, but it made it's action bar to look bad (see below). Now background is cut to the length of the title string and I cant't find any theme property to fix it.( What can be done to avoid it? Related part of styles.xml: ``` <style name="DeviceListTheme" parent="Theme.AppCompat.Dialog"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style> ``` I start the activity using the following code: ``` Intent intent = new Intent(this, DeviceListActivity.class); startActivityForResult(intent, REQUEST_CONNECT_DEVICE); ```

Original source