我想隐藏应用程序标题栏。
Answers:
您可以通过编程方式执行此操作:
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活动主题,它像一种魅力。
您可以通过编程方式执行此操作:或不带操作栏
//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);