Android 欢迎全屏图片详解
其实欢迎界面就是在主Activity之前再添加一个欢迎的Activity。在这个Activity中实现欢迎界面,和其他的Activity用法
是基本一样,只有细微的差别。
1、在Activity的onCreate方法中实现:
1
2
3
4
5
6
7
8
9
|
@Override
ic
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
/**全屏设置,隐藏窗口所有装饰**/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
/**标题是属于View的,所以窗口所有的修饰部分被隐藏后标题依然有效,需要去掉标题**/
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
|
2、在AndroidManifest.xml文件中的相应的欢迎Activity中进行配置
1
2
3
4
5
6
7
8
9
|
<activity
android:name=
".ActivityDemo"
android:label=
"@string/app_name"
android:theme=
"@android:style/Theme.NoTitleBar"
>
<intent-filter>
<action android:name=
"android.intent.action.MAIN"
/>
<category android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
|
也可以将设置成Android:theme="@android:style/Theme.NoTitleBar.Fullscreen"(取消顶部的状态栏)
3、欢迎Activity的layout布局文件
1
2
3
4
5
6
7
|
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:background
=
"@drawable/welcome"
android:orientation
=
"vertical"
>
</
LinearLayout
>
|
上面的android:background="@drawable/welcome"是相对应的图片资源文件
4、运行结果如下
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!