Android 实现画面全屏(取消标题、取消状态栏):
//取消标题
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(R.layout.logo); //Activity样式文件,一定要写在中间
//取消状态栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@color/white"
>
<ImageView
android:id="@+id/logo"
android:src="@drawable/logo_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
java.lang.RuntimeException:Unable to start activity ComponentInfo
这是因为:
java的执行顺序有关!目前遇到的这个问题就是因为在系统运行开始的时候就已经调用父类的构造方法,接着调用setContentView方法展示视图界面。R.layout.main是R.java资源类中的一个属性。当你在调用这个方法之后在声明Widget就会报:android.util.AndroidRuntimeException: requestFeature() must be called before adding content
所以前面的那三句中加载Activity的样式的那句代码一定要写在中间。