Activity如何全屏

使用Android Studio新建的工程,Activity默认继承AppCompatActivity,它提供了更美观的界面,和新特性支持,但是因此也只能使用AppCompat的theme。原来的内置theme有全屏的,但是新的AppCompat的theme却没有提供,实际上我们继承一个AppCompat的theme加上全屏属性,也是一样能工作的。

styles.xml

<!-- Base application theme with full screen -->
<style name="AppTheme.FullScreen" parent="Theme.AppCompat.Light.DarkActionBar">
  <!-- Customize your theme here. -->
  <item name="colorPrimary">@color/colorPrimary</item>
  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  <item name="colorAccent">@color/colorAccent</item>
  <item name="android:windowFullscreen">true</item>
  <item name="windowNoTitle">true</item>
  <item name="windowActionBar">false</item>
</style>
作者:Gacfox
版权声明:本网站为非盈利性质,文章如非特殊说明均为原创,版权遵循知识共享协议CC BY-NC-ND 4.0进行授权,转载必须署名,禁止用于商业目的或演绎修改后转载。
Copyright © 2017-2024 Gacfox All Rights Reserved.
Build with NextJS | Sitemap