Reputation: 4944
Refer to the image below to understand what I'm trying to do. It should be obvious from the image provided. It seems like this should be pretty simple.
The question is, why is the tiled middle section offset by an inconsistent amount for each list entry?
product_list.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:divider="@drawable/product_list_divider"
android:background="@drawable/main_background_bitmap"/>
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No results."/>
</LinearLayout>
product_list_divider.xml
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:src="@drawable/shelf_middle"
android:tileMode="repeat"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_left"
android:gravity="left"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_right"
android:gravity="right"/>
</item>
</layer-list>
Upvotes: 3
Views: 2601
Reputation: 4944
I ended up abandoning the repeat tile mode and did it like this instead:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:src="@drawable/bg"
android:tileMode="repeat" />
</item>
<item>
<bitmap
android:src="@drawable/shelf_shine"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_middle_stretch"
android:gravity="bottom|fill_horizontal"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_side_left"
android:gravity="left|bottom"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_side_right"
android:gravity="right|bottom"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_left"
android:gravity="left|bottom"/>
</item>
<item>
<bitmap
android:src="@drawable/shelf_right"
android:gravity="right|bottom"/>
</item>
</layer-list>
Upvotes: 5