我有一个继承自 AppCompactActivity
的 Activity
.在活动集主题的清单中:
<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></风格>
当我运行活动时,它显示为一个对话框,但显示了标题!我尝试 supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
和 RequestWindowFeature(Window.FEATURE_NO_TITLE)
但标题仍然显示.请告诉我,有什么问题?
编辑
我解决了,只需将android:windowNoTitle
改为windowNoTitle
!因为我正在使用 AppCompactActvity!
如果你有 AppCompatActivity
那么下面的就不行了
requestWindowFeature(Window.FEATURE_NO_TITLE);
简单的方法是在style.xml
文件中设置.
<style name="mytheme" parent="Theme.AppCompat.Light.Dialog"><item name="windowNoTitle">true</item></风格>
<块引用>
它是 name="windowNoTitle"
,而不是 name="android:windowNoTitle"
如果您想以编程方式删除它,请在 onCreate()
getSupportActionBar().hide();
I have an Activity
inherited from AppCompactActivity
. 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)
and RequestWindowFeature(Window.FEATURE_NO_TITLE)
but title still displayed. Please let me know, What is wrong?
Edit
I solve it, only change android:windowNoTitle
to windowNoTitle
! 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 作为没有标题的对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!