Java 如何让actionbar在Android Studio中消失?
我需要让动作栏从屏幕上消失,我已经尝试了所有我能在网上找到的东西,但似乎没有任何效果。我尝试过创建自己的样式,它什么都不做,Java 如何让actionbar在Android Studio中消失?,java,android,xml,android-layout,Java,Android,Xml,Android Layout,我需要让动作栏从屏幕上消失,我已经尝试了所有我能在网上找到的东西,但似乎没有任何效果。我尝试过创建自己的样式,它什么都不做,getActionbar().hide(),它给我一个错误并且不编译,requestWindowFeature(Window.FEATURE\u NO\u TITLE),它也不做任何事情。我真的需要摆脱那个动作条。我正在使用传感器横向定位,但我已经尝试过改变它,但它没有改变任何东西 舱单: <?xml version="1.0" encoding="utf-8
getActionbar().hide()
,它给我一个错误并且不编译,requestWindowFeature(Window.FEATURE\u NO\u TITLE)代码>,它也不做任何事情。我真的需要摆脱那个动作条。我正在使用传感器横向定位,但我已经尝试过改变它,但它没有改变任何东西
舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tanques">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen>
<activity android:name=".MainActivity" android:screenOrientation="sensorLandscape" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
显示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tanques">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
创建hideNavigationBar()
方法并在onCreate()中调用它
检查这个答案,它可能会帮助你
quita el tema del Main activity我不完全确定代码应该放在哪里,这是我的原始代码:super.onCreate(savedInstanceState)之后;在setContentView之前(R.layout.activity_main);就像在我的帖子中,super.onCreate(savedInstanceState);重写fun onCreate(savedInstanceState:Bundle?{super.onCreate(savedInstanceState)requestWindowFeature(Window.FEATURE_NO_TITLE)Window.setFlags(WindowManager.LayoutParams.FLAG_全屏,WindowManager.LayoutParams.FLAG_全屏)setContentView(R.layout.activity_图片查看器)}setContentView(R.layout.activity_main);像这个?是的,就这些,试着告诉我是否正确
package com.example.tanques;
import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity implements JoystickView.JoystickListener, JoystickHorizontal.JoystickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button ShootLeft= findViewById(R.id.ShootLeft);
Button ShootRight= findViewById(R.id.ShootRight);
ShootLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){
Log.d("Button","ShootLeft");
}});
ShootRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){
Log.d("Button","ShootRight");
}});
}
@Override
public void onJoystickMoved(float Percent, int source) {
switch(source){
case R.id.JoystickLeft:
Log.d("Joystick", "JoystickLeft" + " Percentage: " +Math.round(Percent));
break;
case R.id.JoystickRight:
Log.d("Joystick", "JoystickRight" + " Percentage: " +Math.round(Percent));
break;
case R.id.JoystickTurret:
Log.d("Joystick", "JoystickTurret" + " Percentage: " +Math.round(Percent));
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tanques">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"/>
</resources>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//add this two lines to your code to hide the system bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN , WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
//this hides the navigation bar at the bottom of your device
hideNavigationBar();
final Button ShootLeft= findViewById(R.id.ShootLeft);
Button ShootRight= findViewById(R.id.ShootRight);
ShootLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){
Log.d("Button","ShootLeft");
}});
ShootRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v){
Log.d("Button","ShootRight");
}});
}
private void hideNavigationBar(){
getWindow().getDecorView()
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
);
}