You can take a strip from the image and use repeat like this 
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/your_pattern"
    android:tileMode="repeat" />
EDIT : If you wanted programmatically
1- crop from the image using this code from cut the portion of bitmap :
private Bitmap cropBitmap1()
{
    Bitmap bmp2 = BitmapFactory.decodeResource(this.getResources(), R.drawable.image1); 
    Bitmap bmOverlay = Bitmap.createBitmap(bmp2.getWidth(), 1, Bitmap.Config.ARGB_8888);
    Paint p = new Paint();
    p.setXfermode(new PorterDuffXfermode(Mode.CLEAR));              
    Canvas c = new Canvas(bmOverlay); 
    c.drawBitmap(bmp2, 0, 0, null); 
    c.drawRect(30, 30, 100, 100, p);
    return bmOverlay;
}
2- The returned bitmap , convert it to bitmapdrawable:
BitmapDrawable navigationBackground =new BitmapDrawable(getResources(),bitmap);
navigationBackground.setTileModeX(Shader.TileMode.REPEAT);