android studio 启动界面
时间: 2023-11-21 13:59:21 浏览: 106
在Android Studio中创建启动界面有多种方法,以下是其中两种常用的方法:
1. 使用ImageView显示启动界面图片:
在res目录下创建文件夹drawable-hdpi,并将启动界面图片放入该文件夹中。然后在启动界面的布局文件中使用ImageView来显示该图片。例如,创建一个名为activity_splash.xml的布局文件,内容如下:
```xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/splash_image"
android:scaleType="centerCrop" />
</RelativeLayout>
```
其中,@drawable/splash_image是启动界面图片的资源ID。
2. 使用Theme设置启动界面样式:
在res/values/styles.xml文件中定义一个启动界面的主题样式,例如:
```xml
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_image</item>
</style>
```
其中,@drawable/splash_image是启动界面图片的资源ID。
然后,在AndroidManifest.xml文件中将启动界面的主题样式应用到启动的Activity上,例如:
```xml
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
```
其中,SplashActivity是启动界面的Activity类名。
阅读全文
相关推荐


















