OutOfMemoryError - 图层列表图像背景

时间:2016-12-15 02:38:41

标签: android out-of-memory android-bitmap layer-list

我的背景图片是PNG 375×667
请注意,在我的活动setContentView()中使用onCreate() NOT 我纯粹是在利用主题 使用正常的活动布局,用户将看到一个空白的黑暗屏幕2-3秒,然后他们第一次启动应用程序时可以看到启动画面图像==> 我想要的东西 当用户打开应用程序时,我需要立即显示启动画面图像 有些人使Splash屏幕透明,这意味着用户第一次看到2-3秒没有任何反应==> 不可接受对我来说

Manifest.xml

<activity
            android:name=".views.activities.SplashActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme"
            android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

styles.xml

<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:background">@drawable/bg_splash</item>
    </style>

bg_splash.xml

<item
    android:drawable="@android:color/black"/>

<item
    android:drawable="@drawable/splash_full_tiny"
    android:gravity="center">
</item>

这只发生在一些设备上:

  • Vodafone Smart ultra 6
  • A1601(Oppo)
  • SM-A800I(三星)

3 个答案:

答案 0 :(得分:0)

尝试添加此android:largeHeap =“true”

<application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:largeHeap="true"
        ></application>

答案 1 :(得分:0)

尝试在应用标记中应用您的SplashTheme样式,或者您可以向appsTheme添加背景,与splashtheme相同。这将快速显示您的飞溅图像。确保一旦实施检查所有活动。因为它将在您的应用程序中用作背景。在具有透明背景的所有活动中,它将其显示为背景。我希望这对你有帮助。

答案 2 :(得分:-1)

为此,您应该为不同的设备或任何小图像使用不同的图像。