自定义控件边框

最近有个要要实现以下的小功能的需求,话说我也该吐槽以下这个和.9png相比我觉得这两个不知道闹那样的,不过这两种都能实现以下的小需求

其中listview中搜索历史记录的半角边框,是用自定义边框做的

只需要在该listview中所设置的adapter中的view中的layout里面添加background属性,然后在drawable中添加以下

文件(该文件当成图片使用)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >

    <!--&lt;!&ndash; 渐变 &ndash;&gt;
    <gradient
        android:startColor="#B5E7B8"
        android:endColor="#76D37B"
        android:angle="270"
        />-->

    <!-- 描边 -->
      <stroke android:width="1dip"
     android:color="#cccccc"
     />

    <!-- 实心 -->
    <!--  <solid android:color="#FFeaeaea"
     />  -->

    <!-- 圆角 -->
    <corners
        android:bottomRightRadius="200dip"
        android:bottomLeftRadius="200dip"
        android:topLeftRadius="200dip"
        android:topRightRadius="200dip"
        />
</shape>

     

原文地址:https://www.cnblogs.com/mrszhou/p/7078590.html