Full Screen Theme for AppCompat

2019-01-01 07:44发布

I would like to know how can I apply full screen theme ( no title bar + no actionbar ) to an activity. I am using AppCompat library from support package v7.

I've tried to applied android:theme="@android:style/Theme.NoTitleBar.Fullscreen" to my specific activity but it crashed. I think it's because my application theme is like this.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

I also have tried this

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

which only hides title bar but not the action bar. My current workaround is that hiding the actionbar with

getSupportActionBar().hide();

15条回答
何处买醉
2楼-- · 2019-01-01 08:17

This theme only works after API 21(included). And make both the StatusBar and NavigationBar transparent.

<style name="TransparentAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="windowActionBar">false</item>
  <item name="windowNoTitle">true</item>
  <item name="android:statusBarColor">@android:color/transparent</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:navigationBarColor">@android:color/transparent</item>
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowContentOverlay">@null</item>
</style>
查看更多
墨雨无痕
3楼-- · 2019-01-01 08:19

just this ?

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen">
    <item name="android:windowFullscreen">true</item>
</style>
查看更多
余生请多指教
4楼-- · 2019-01-01 08:21
requestWindowFeature(Window.FEATURE_NO_TITLE);
查看更多
裙下三千臣
5楼-- · 2019-01-01 08:21

To remove title bar in AppCompat:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    }
查看更多
无与为乐者.
6楼-- · 2019-01-01 08:25

When you use Theme.AppCompat in your application you can use FullScreenTheme by adding the code below to styles.

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

and also mention in your manifest file.

<activity
   android:name=".activities.FullViewActivity"
   android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" 
/>
查看更多
浅入江南
7楼-- · 2019-01-01 08:27

Simply at this guys to your Style:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item> </style>
查看更多
登录 后发表回答