Android stroke 边框线 某一边

来源:互联网 发布:网络诈骗案案例 编辑:程序博客网 时间:2024/06/06 15:56

有时候需要给View加边框线,我们经常是四边一起加,就像这样:

<shape xmlns:android="http://schemas.android.com/apk/res/android">       <solid android:color="#89c997"></solid>       <stroke android:width="0.5dp" android:color="#c3c3c3"></stroke></shape>
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

然而有时候,我们并不需要四边都会有边框,那我们就需要用到layer-list标签,比如我们只给下加边框:

<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="#ffffff"/>               <stroke                   android:width="1dp"                   android:color="#ff0000"/>          </shape>     </item></layer-list>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

在这个item中,你可以指定哪些边不加边框。

原创粉丝点击