Android: Center splash screen image(安卓:中央闪屏图片)
问题描述
我有一个带有闪屏的应用程序,闪屏在小型设备上看起来很好,但在大平板电脑(模拟器)上看起来很糟糕。所以我把背景改成了wrap_content
。但它看起来与屏幕的一侧对齐,有人能告诉我一种使背景图像居中的方法吗?这是我的plash.xml-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/splash">
</LinearLayout>
推荐答案
您实际上既不需要LinearLayout
也不需要RelativeLayout
,请使用更轻量级的FrameLayout
。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/splash"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
这篇关于安卓:中央闪屏图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!