Android activity with multiple repeating backgrounds
I am still new to android and I am having trouble creating a layout with two backgrounds that alternate in the x but not the y direction.
I scoffed at what I am trying to create here ...
http://img153.imageshack.us/img153/6008/cnbackground.png
So the top repeats horizontally, then there is a flat roll section in the middle where I will center my content, and then the grass repeats horizontally at the bottom.
Has anyone tried to do something like this before?
John
a source to share
Here's a good simple tutorial on the part about re-background image:
http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html
In terms of layout, I would include RelativeLayout as the main parent layout, and then you have three sub layouts to represent the top, middle and bottom. Use android: layout_alignParentTop in the top layout, android: layout_alignParentBottom at the bottom, and the middle content layout should have android: layout_above and android: layout_below attributes set to bottom and top-bottom and bottom (respectively).
a source to share
You can simulate repeat-x using a layer list as drawable. You draw a bitmap of both x and y and then use a solid offset shape to fill in the repeating y images. Not perfect, but will do the job.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:src="@drawable/icon"
android:tileMode="repeat" />
</item>
<item android:top="60dp">
<shape >
<solid android:color="#FF000000" />
</shape>
</item>
</layer-list>
a source to share