Hello! I launch the second activation in the standard way as follows:

public void showCalendarActivity() { Intent intentTask = new Intent(this, CalendarActivity.class); startActivityForResult(intentTask, 1); } 

and get:

enter image description here

If I run the second activation as a Dialog:

 public void showCalendarActivity() { Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.activity_calendar); dialog.show(); } 

I get:

enter image description here

Is there a way to get this:

enter image description here

Those. Dialog, but with ActionBar above?

UPDATE

Using the tips, he added the Toolbar and in the manifest he set the android:theme="@style/Theme.AppCompat.Dialog" style android:theme="@style/Theme.AppCompat.Dialog" . I call the first way, as usual activit:

 Intent intentTask = new Intent(this, CalendarActivity.class); startActivityForResult(intentTask, 1); 

It turned out something like the desired result:

enter image description here

But for some reason the calendar became "transparent". How to fix this problem? And also how to remove the title from the toolbar? In the layout layout, the title property is not set. And how to center the top inscription?

enter image description here

To make it like this:

enter image description here

And even better to remove the upper inscription too.

  • 3
    Try adding Toolbar to the dialogue markup - Yuriy SPb
  • @YuriySPb, thank you, good advice, updated the question, please look - badadin
  • one
    The title of the toolbar can be removed by the title attribute - in the markup or in the code. The title of the dialogue is also in the code, you can somehow remove it by requesting NoTitle somehow. To center the text of the title of the dialogue - it is difficult and crutch - better to remove. It became transparent due to some attributes of the default dialog style. Create your own style-successor dialog and put down the necessary attributes. - Yuriy SPb
  • @YurySPb, thanks, I will try! - badadin

1 answer 1

To display your Activity in the form of a dialog in the manifest file, set the following topic:

 <activity android:theme="@android:style/Theme.Dialog" /> 

Or, when using the support library:

  <activity android:theme="@style/Theme.AppCompat.Dialog"/> 
  • Thank you when using android: theme = "@ style / Theme.AppCompat.Dialog" activates itself as Dialog, but there are new problems, updated the question, please see - badadin
  • one
    to return the display, try the android theme: theme = "@ style / Theme.AppCompat.Light.Dialog", to remove the title, delete the android: label parameter of your Activit in the manifest file - ZigZag
  • Installing android: theme = "@ style / Theme.AppCompat.Light.Dialog" helped, but the label had to be set to android: label = "", otherwise the default label was set, with the name of the application. In principle, it remains to figure out how to remove the empty tip, thanks! - badadin