将Android 中ListView的边线设为虚线

fmms 12年前
     <div class="paragraph">     <p>ListView中的底部边线可以通过 divider 属性进行设置, 但是没有提供类似CSS border dashed 的选项, 如果需要设置边线为虚线需要使用 一张图片 和 一个bitmap xml文件.</p>    </div>    <div class="paragraph">     <div class="title">      背景图片:     </div>     <p>图片可以使用网页中常用的虚线边框背景图, 类似与CSS中出现的 background repeat-x 类型图片, 一般是一个 1x2px 的透明背景图片. 可以参考这张图片:</p>    </div>    <div class="imageblock"></div> Bitmap xml文件:    <pre class="brush:xml; toolbar: true; auto-links: false;"><?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android"         android:src="@drawable/bg_dot_dashed"         android:tileMode="repeat" /></pre>    <div class="content">     其中 android:src 设置为刚才的那个背景图片.    </div> ListView设置:    <pre class="brush:xml; toolbar: true; auto-links: false;"><ListView     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:divider="@drawable/dashed_line"     android:dividerHeight="1dip" /></pre>    <div class="content">     其中 android:divider 设置为刚才的那个Bitmap xml文件即可.    </div>    <div class="title">     相关内容    </div>    <p>另外附带的说一下如何在任何地方插入一条横线作为分割符, 效果类似与CSS中的 border-bottom: 1px solid #ccc;</p>    <pre class="brush:xml; toolbar: true; auto-links: false;"><LinearLayout>     android:background="#CCC"     android:layout_width="1px"     android:layout_height="fill_parent" </LinearLayout></pre>    <p></p>