Mat*_*hew 24 android background splash-screen android-manifest xamarin.android
如何在活动主题/样式中使用背景图像?
如果我使用颜色这样做:
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/custom_theme_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)
它工作正常,但如果我用以下代码替换:
<item name="android:windowBackground">@drawable/splash_image</item>
Run Code Online (Sandbox Code Playgroud)
图像显示正确,但所有内容都被压缩到屏幕左上角的一个小块中.状态栏下方的阴影也会被切断或混乱.
我正在使用Mono for Android,图像是一个有效的九补丁png.
Vic*_*cVu 16
我也不使用主题,所以在我要添加的活动的布局中
android:background="@drawable/splash_image"
Run Code Online (Sandbox Code Playgroud)
我不使用主题或任何东西,所以我不确定这将如何影响这一点,但我设置我的背景如下:
getWindow().setBackgroundDrawableResource(R.drawable.background_image);
Run Code Online (Sandbox Code Playgroud)
在onCreate
我的解决方案是将android:windowBackground更改为android:background.
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="Theme.Splash" parent="android:Theme">
<item name="android:background">@drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我需要一个看起来像我的应用程序初始活动的启动图像并遇到同样的问题.我很幸运使用windowContentOverlay而不是windowBackground.drawable出现在状态栏下方,与真实布局完全相同.它适用于Android 2.2,Android 3.0和Android 4.1.
这是我的风格:
<style name="SplashTheme" parent="android:style/Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@drawable/splash</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的splash.xml drawable使用layer-list模仿我的用户界面标题:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--- Background; tile is broken on Android 2.2 so just have super wide background that will get clipped -->
<item>
<bitmap android:gravity="top|left" android:src="@drawable/splash_background" />
</item>
<!--- Icon left justified -->
<item>
<bitmap android:gravity="top|left" android:src="@drawable/header_icon" />
</item>
<!--- Buttons/etc right justified -->
<item>
<bitmap android:gravity="top|right" android:src="@drawable/splash_buttons" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
如果您的应用使用它,我相信ActionBar还有一些内置的方法可以解决这个问题.该MonoIO样品似乎有这样的启动图像.
| 归档时间: |
|
| 查看次数: |
44769 次 |
| 最近记录: |