我想隐藏应用程序的标题栏。
您可以通过编程实现:
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class ActivityName extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
或者您可以通过您的AndroidManifest.xml
文件完成:
<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</activity>
编辑:我添加了一些代码,以便可以在全屏模式下显示,因为这似乎是你想要的。
使用
<activity android:name=".ActivityName"
android:theme="@android:style/Theme.NoTitleBar">
@style/Theme.AppCompat
,因此它不允许我使用@android:style/Theme.NoTitleBar
作为活动主题。我改用了@style/Theme.AppCompat.NoActionBar
作为活动主题,结果非常完美。 - omikes你可以通过编程实现:或者在没有操作栏的情况下
//It's enough to remove the line
requestWindowFeature(Window.FEATURE_NO_TITLE);
//But if you want to display full screen (without action bar) write too
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.your_activity);