Search code examples
androidtexturesnine-patch

NinePatch Background and Android


I am looking to add a Noisy Background in my android app. The texture is perfect and I can create a NinePatch image, but when I actually use it in the app it stretches causing lines throughout the background. Any idea what a better way would be to implement this type of texture?

I would also be looking to use something similar for the actionbar.

NoisyGrey


Solution

  • 9-Patch will stretch, You have to specify which area should stretch in the image. Why dont you try repeating your drawable. like so:

    <xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    android:id="@+id/YourLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/backrepeat"
    >
    

    then in an xml called backrepeat.xml

    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/back" 
        android:tileMode="repeat" />