簡體   English   中英

高級android布局:從圖層列表中創建ListView分隔符

[英]Advanced android layout: making a ListView divider from a layer-list

請參閱下圖以了解我正在嘗試做什么。 從提供的圖像中可以明顯看出。 看起來這應該很簡單。

問題是,為什么平鋪的中間部分偏移了每個列表條目的不一致數量?

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>

圖片有助於解釋情況......

我最終放棄了重復平鋪模式,而是這樣做了:

<?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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM