Как установить фоновое изображение для макета с помощью scroolview, потому что когда я добавляю ImageView в код ниже, scroolview начинает работать очень медленно. Изображение имеет 700kb. Если я установил android:background="@drawable/background04"
в relativeLayout, scroolview также работает очень медленно.Медленная прокрутка с фоновым изображением
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.scrollview.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/background04"
android:alpha="0.8"
android:layout_centerHorizontal="true" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true">
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView2" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView3" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView4" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView5" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView6" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView7" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView8" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView9" />
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView10" />
</LinearLayout>
</ScrollView>
Edit:
Для тестирования я использую HTC Desire 820.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aapps.scrollview">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Logcat:
05-03 10:48:04.750 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): bitmap = 0x55a971acb0
05-03 10:48:04.750 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): pixelRef ID = 415
05-03 10:48:05.250 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): bitmap = 0x55a971acb0
05-03 10:48:05.250 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): pixelRef ID = 415
05-03 10:48:05.850 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): bitmap = 0x55a971acb0
05-03 10:48:05.850 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): pixelRef ID = 415
05-03 10:48:06.330 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): bitmap = 0x55a971acb0
05-03 10:48:06.330 17843-17891/com.aapps.scrollview E/OpenGLRenderer: CacheDebug: generateTexture() in TextureCache::get(, if (!texture): pixelRef ID = 415
05-03 10:48:06.840 17843-17843/com.aapps.scrollview I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread.
попробовать с добавлением этого андроида: largeHeap = «истина» в вашем приложении тега манифеста –
и прочитать http://developer.android.com/training/displaying-bitmaps/cache-bitmap .html –