先进的机器人布局:从图层列表制作一个ListView分图层、机器人、布局、先进

由网友(这么近那么远)分享简介:请参考下面的图片来了解我想要做的。它应该是从所提供的图像明显。看起来这应该是pretty的简单。Refer to the image below to understand what I'm trying to do. It should be obvious from the image provided. It...

请参考下面的图片来了解我想要做的。它应该是从所提供的图像明显。看起来这应该是pretty的简单。

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>

推荐答案

我最终放弃了重复平铺模式,做到了而不是像这样:

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>
阅读全文

相关推荐

最新文章