需要下划线的地方<View
     android:background="@drawable/shape_line" 
     android:layout_width="fill_parent" 
     android:layout_height="1.0px" />以下是drawable中的shape_line.xml<shape android:shape="rectangle"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffe0e0e0" />
</shape>楼主可以试试

解决方案 »

  1.   

    恩,这种方法我试也过,能实现,总之谢谢你。但我就是想问问可以通过直接做为背景来实现么,而不是另写个View。
      

  2.   

    通常是用layer-list来模拟一条线,shape本身是无法画一条线的<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <item
            android:left="-2dp"
            android:right="-2dp"
            android:top="-2dp">
            <shape>
                <solid android:color="#00FFFFFF" />            <stroke
                    android:width="1px"
                    android:color="#cc0000" />
            </shape>
        </item></layer-list>
      

  3.   

    用<layer-list    多层shape,在需要留线的地方 设置padding 比如 第一层shape  无边线  全黑
    第二层  shape peddingtop1dp 其余全白  
    那么效果就是 上面1条黑线