简体   繁体   English

如何隐藏弹出活动的标题栏

[英]How to hide Title Bar of a pop-up activity

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 我是通过在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. 它可以按预期工作,但出现的问题是Appname作为标题。 I want to make it appear as AlertDialog. 我想使其显示为AlertDialog。 How to fix this? 如何解决这个问题?

I also cant use setTitle("") or label="" because empty space is left where appname was before. 我也不能使用setTitle(“”)或label =“”,因为在appname之前的位置留有空白。

您可以在Activity中简单地调用setTitle("")函数。

Add this code to the top of the onCreate() method of the Activity: 将此代码添加到Activity的onCreate()方法的顶部

setTheme(R.style.{style}
  • The {style} should be ended with NoActionBar . {style}应该以NoActionBar ie R.style.Theme_AppCompat_NoActionBar 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! 希望这个答案有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM