[英]Advanced android layout: making a ListView divider from a layer-list
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 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 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>
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.