Sunday, 19 April 2015

Repeating Background Textures in Android


  • Pick something from Subtle Patterns, e.g. irongrip.png and drop it in your drawable-hdpi folder
  • Make a BitmapDrawable, e.g. irongrip_repeating.xml
1234
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/irongrip"
android:tileMode="repeat" />
  • Apply it to a View
123456
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/irongrip_repeating"
android:orientation="vertical">
</LinearLayout>
view rawmain.xml hosted with ❤ by GitHub
The result:
A pretty simple way to spruce up an app, just don't go overboard. Happy hacking!

No comments:

Post a Comment