Hide title in full screen (AppCompatActivity)

I am trying to hide title barin full screen. When I try to use Activity, the title bar disappears. But when I use AppCompatActivity, it still remains. Any idea why this is happening? Should I change something else, like a manifest? Here is the code I used to hide the title bar and go into full screen mode:

public class MoreInfoNotification extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.more_info_notification);
}

Thanks. Hurrah!

+4
source share
2 answers

When using AppCompatActivity to remove an ActionBar / Title, the theme of this action; specified in the file styles.xmlshould be one of the NoActionBar themes:

Theme.AppCompat.Light.NoActionBar

Theme.AppCompat.NoActionBar
+1
source

Got it.

theme MoreInfoNotification .

<!--Theme for parent activity--> 
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<!--Theme for new activity-->
<style name="MoreOnNotificationTheme" parent="AppTheme.NoActionBar">
    <item name="android:windowNoTitle">true</item>
</style>

MoreInfoNotification:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

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

Source: https://habr.com/ru/post/1623325/


All Articles