简体   繁体   English

如何隐藏标题Android

[英]How to hide Title Android

i am trying to make a mini-game program and i cant get the title bar to go away i have already tried the following getActionBar().hide(); 我正在尝试制作一个迷你游戏程序,但标题栏消失了,我已经尝试过以下getActionBar().hide(); , requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE); here is what i have so far. 这是我到目前为止所拥有的。

package com.example.marcus.game;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;

public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
}

XML XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
tools:context="com.example.marcus.game.MainActivity"
android:background="#752fdf">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Large Text"
    android:id="@+id/textView"
    android:layout_alignParentTop="true"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    android:layout_centerHorizontal="true" />
</RelativeLayout>

Add this style to your styles.xml: 将此样式添加到您的styles.xml中:

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

You can also add : 您还可以添加:

    <item name="android:windowTranslucentStatus">true</item>

to your v21 style. 您的v21风格。

Change your androidmanifest.xml to use the style: 更改您的androidmanifest.xml以使用样式:

    <activity
        android:name="MainActivity"
        android:theme="@style/AppTheme.Fullscreen"/>

see About the Full Screen And No Titlebar from manifest 从清单中查看关于全屏且无标题栏

add

android:theme="@android:style/Theme.NoTitleBar"

to your activity or application in the manifest 清单中您的活动或应用程序

and change 并改变

"extends AppCompatActivity"

to

"extends Activity"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM