0

I created an activity which is shown as pop up/ Dialog by following answers given in this question.

I did it by adding these lines in AndroidManifest

 <activity
        android:name=".package.Activity"
        android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />

It works well as intended but the problem it shows Appname as title. I want to make it appear as AlertDialog. How to fix this?

I also cant use setTitle("") or label="" because empty space is left where appname was before.

Nux
  • 5,890
  • 13
  • 48
  • 74
  • just add `android:label=""` to the activity tag – denvercoder9 Jul 03 '18 at 14:22
  • 1
    Possible duplicate of [Android activity as dialog, but without a title bar](https://stackoverflow.com/questions/6325018/android-activity-as-dialog-but-without-a-title-bar) – ADM Jul 03 '18 at 14:26

2 Answers2

2

Add this code to the top of the onCreate() method of the Activity:

setTheme(R.style.{style}
  • The {style} should be ended with NoActionBar. i.e. R.style.Theme_AppCompat_NoActionBar

  • And most importantly, add the code before these two lines of code (add it to the top of the method):

    super.onCreate(savedInstanceState);
    setContentView(R.layout.{your layout});
    

Hope this answer helped!

1

You can simply call the setTitle("") function from within your Activity.

Manan Adhvaryu
  • 323
  • 3
  • 14