Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action bar looks cut while using Theme.AppCompat.Dialog

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);
like image 667
Vyacheslav Orlovsky Avatar asked Sep 29 '22 17:09

Vyacheslav Orlovsky


1 Answers

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.

like image 185
Farbod Salamat-Zadeh Avatar answered Oct 03 '22 08:10

Farbod Salamat-Zadeh