AppCompatActivity因为没有冠军的对话 [英] AppCompatActivity as a dialog without title
问题描述
我从 AppCompactActivity
继承了活动。清单中的活动设置主题:
<样式名称=Theme.custom父=Theme.AppCompat.Light.Dialog>
<项目名称=机器人:windowNoTitle>真< /项目>
<项目名称=colorPrimary> @彩色/初级与LT; /项目>
<项目名称=colorPrimaryDark> @彩色/ primary_dark< /项目>
<项目名称=colorAccent> @颜色/重音< /项目>
<项目名称=colorButtonNormal> @颜色/重音< /项目>
<项目名称=机器人:按钮样式> @风格/&的ButtonStyle LT; /项目>
< /风格>
当我运行的活动,它显示为一个对话框,但标题所示!我尝试 supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
和 RequestWindowFeature(Window.FEATURE_NO_TITLE)
,但标题仍然显示。请让我知道,什么是错的?
修改
我解决这个问题,只能换的android:windowNoTitle
到 windowNoTitle
!因为我用AppCompactActvity!
如果您有 AppCompatActivity
那么下面将无法正常工作
requestWindowFeature(Window.FEATURE_NO_TITLE);
简单的方法是将其设置在 style.xml
文件。
<样式名称=mytheme的父=Theme.AppCompat.Light.Dialog>
<项目名称=windowNoTitle>真< /项目>
< /风格>
是
NAME =windowNoTitle
,而不是NAME =机器人:windowNoTitle
块引用>如果您希望以编程方式删除它,然后加入
的onCreate)以下(
getSupportActionBar()隐藏()。
I have an
Activity
inherited fromAppCompactActivity
. in manifest for activity set theme:<style name="Theme.custom" parent="Theme.AppCompat.Light.Dialog"> <item name="android:windowNoTitle">true</item> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary_dark</item> <item name="colorAccent">@color/accent</item> <item name="colorButtonNormal">@color/accent</item> <item name="android:buttonStyle">@style/ButtonStyle</item> </style>
When I run activity, it shows as a dialog, but title is shown! i try
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
andRequestWindowFeature(Window.FEATURE_NO_TITLE)
but title still displayed. Please let me know, What is wrong?
Edit
I solve it, only change
android:windowNoTitle
towindowNoTitle
! because i am use AppCompactActvity!解决方案If you are having
AppCompatActivity
then the following won't work
requestWindowFeature(Window.FEATURE_NO_TITLE);
The simple way is to set it in the
style.xml
file.<style name="mytheme" parent="Theme.AppCompat.Light.Dialog"> <item name="windowNoTitle">true</item> </style>
It is
name="windowNoTitle"
, notname="android:windowNoTitle"
If you want to remove it programmatically then add the following in
onCreate()
getSupportActionBar().hide();
这篇关于AppCompatActivity因为没有冠军的对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!