简体   繁体   English

在Android应用程序中隐藏工具栏

[英]Hide toolbar in android application

Im trying to make a game for android using the canvas drawing method, but there's one problem. 我正在尝试使用画布绘制方法为Android开发游戏,但存在一个问题。 All my sprites were made for the specific aspect ratio of the screen, the the game doesn't take up the entire screen. 我所有的精灵都是针对屏幕的特定纵横比制作的,游戏不会占据整个屏幕。 Here's what it looks like. 这是它的样子。 在此处输入图片说明

Im not sure what that area to the right with the three buttons is, but I want to hide it so I can take advantage of the entire screen. 我不确定这三个按钮在右边的区域是什么,但是我想将其隐藏起来,以便可以利用整个屏幕。 Could someone please let me know how? 有人可以让我知道怎么做吗? Thanks. 谢谢。

EDIT: Here's the code for my MainActivity class. 编辑:这是我的MainActivity类的代码。

package com.example.beaverduck.functionflyer.engine;

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

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(new GamePanel(this));
    }
}

Try using this in your launcher screen. 尝试在启动器屏幕中使用它。

 requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

Check once in AndroidManiifest.xml that the theme you are using is without action bar and then check styles.xml too. 在AndroidManiifest.xml中检查一次您正在使用的主题没有操作栏,然后也检查styles.xml。

AndroidManifest.xml AndroidManifest.xml中

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

styles.xml styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

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

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