How to make android app’s background image repeat
Ok, here’s what I’ve got in my app. It includes a hack to prevent ListViews from going black while scrolling. drawable/app_background.xml:
1 2 3 4 |
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/actual_pattern_image" android:tileMode="repeat" /> |
values/styles.xml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="app_theme" parent="android:Theme"> <item name="android:windowBackground">@drawable/app_background</item> <item name="android:listViewStyle">@style/TransparentListView</item> <item name="android:expandableListViewStyle">@style/TransparentExpandableListView</item> </style> <style name="TransparentListView" parent="@android:style/Widget.ListView"> <item name="android:cacheColorHint">@android:color/transparent</item> </style> <style name="TransparentExpandableListView" parent="@android:style/Widget.ExpandableListView"> <item name="android:cacheColorHint">@android:color/transparent</item> </style> </resources> |
AndroidManifest.xml:
1 |
<application android:theme="@style/app_theme"> |