The action bar looks cut out when using Theme.AppCompat.Dialog

I wanted to make one of my actions look like a dialogue and used Theme.AppCompat.Dialog theme for it, but it made the action bar look bad (see below).

Now the background is trimmed to the length of the title bar, and I cannot find any theme property to fix it. (

What can be done to avoid this?

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 run the action using the following code:

 Intent intent = new Intent(this, DeviceListActivity.class); startActivityForResult(intent, REQUEST_CONNECT_DEVICE); 
+5
source share
4 answers

First, when I ran into this problem, I tried to use supportRequestWindowFeature(Window.FEATURE_NO_TITLE); but it didn’t work for me and it didn’t influence.

An alternative method to remove the panel at the top of the activity of the dialog box is to create a custom style and apply it to this activity.

In styles.xml create a new style:

 <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 android:theme="@style/MyCustomDialog" to your activity.

Of course, MyCustomDialog can be renamed to anything.

+4
source

Use DialogWhenLarge instead of the standard dialog style:

 <style name="MyDialogTheme" parent="@style/Theme.AppCompat.Light.DialogWhenLarge"> ... </style> 
0
source

I solved the same problem as follows:

Activity:

 public class MyActivity extends android.support.v4.app.FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_layout); setTitle("View task"); } } 

Topic:

 <style name="Theme.MyDialog" parent="@style/Theme.AppCompat.Light.Dialog"> <item name="android:windowNoTitle">false</item> </style> 

manifest:

 <activity android:name=".MyActivity" android:theme="@style/Theme.MyDialog"/> 

Result:

W3jfm.png

0
source

enter image description here

Works

 <style name="AppThemeDialog" parent="Theme.AppCompat.Light.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:spinnerStyle">@style/holoSpinner</item> </style> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); setTitle("Batches"); } 
0
source

Source: https://habr.com/ru/post/1213605/


All Articles