If you have a tile image and want to repeat it as a background of your Android Activity screen this can be achieved using android:tileMode property, lets see an example,
Step 1: Select your texture image that you want to repeat,
Example: Texture Image to RepeatStep 2: Create an xml under res -> drawable having bitmap tag with android:tileMode="repeat" attribute,
Place the image in res folder<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/texture" android:tileMode="repeat" />
Step 3: Now include this bitmap in the activity layout background attribute,
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/app_bg" > </RelativeLayout>
Result:
- Increase Android Emulator Timeout time
- Android : Remove ListView Separator/divider programmatically or using xml property
- Error : Invalid key hash.The key hash does not match any stored key hashes
- How to Change Android Toast Position?
- Android Alert Dialog with Checkboxes example
- Android : No Launcher activity found! Error
- Android Development: Spinners with Example
- Failed to sync Gradle project Error:failed to find target android-23
- INSTALL_FAILED_INSUFFICIENT_STORAGE Android Error
- Disable Fading Edges Scroll Effect Android Views
- How to create Toast messages in Android?
- Channel 50 SMSes received every few minutes Android Phones
- Android xml error Attribute is missing the Android namespace prefix [Solution]
- Create Custom Android AlertDialog
- How To Disable Landscape Mode in Android Application
- Android Development - How to switch between two Activities
- incorrect line ending: found carriage return (\r) without corresponding newline (\n)
- Generate Facebook Android SDK keyhash using java code
- Android Error Generating Final Archive - Debug Certificate Expired
- 21 Useful Android Emulator Short-cut Keyboard Keys
- Android RatingBar Example
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020
- Download interrupted: Unknown Host dl-ssl.google.com Error Android SDK Manager
- fill_parent vs match_parent vs wrap_content
- Android : Connection with adb was interrupted 0 attempts have been made to reconnect
- [Solved] Dynamic Web Module 3.0 requires Java 1.6 or newer Mac OSX - Mac-OS-X
- java: ']' expected error [fixed] - Java
- Meaning of [::-1] in Python Slicing - Python
- How to Add New Entry to ZSH PATH - zsh
- How to Make Microsoft Excel Default Application on Mac - MacOS
- Center Align TextView Android Horizontally or Vertically - Android
- Keyboard shortcut to close tab in Notepad++ - NotepadPlusPlus
- How to install npm on Ubuntu - Linux
![Output Output](https://code2care.org/pages/repeat-tile-background-android-activity/images/android_bac_ground_repeat_image_2.png)
Output
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Android,
More Posts: