基本步骤:
在drawable文件夹下建立一个shape.xml

shape.xml:

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">        <solid android:color="#FF8C2E"/>            <corners android:radius="360dip"/>        <padding        android:left="10dp"        android:top="10dp"        android:right="10dp"        android:bottom="10dp"        />shape>

在主界面中的main.xml:

                                 android:id="@+id/agree"
                 android:layout_width="125dp"
                 android:layout_height="50dp"
                 android:background="@drawable/shape"
               />
              

   

注意:在shape文件中,

表示绘制椭圆:

 android:shape="oval"

表示绘制线条:

android:shape="line"

表示圆形:

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="oval">        <solid android:color="@color/colorAccent"/>            <corners android:radius="180dip"/>        <padding        android:left="5dp"        android:top="10dp"        android:right="5dp"            根据字数多少 大小  边距稍微调一下就能出来        android:bottom="10dp"        />shape>    


表示绘制矩形;加上半径,则可以绘制圆角矩形。

android:shape="rectangle"

更多相关文章

  1. Android开发历程之三
  2. Android(安卓)shape 绘制图形的实例详解
  3. Android(安卓)OpenGL ES基础教程
  4. Android百度地图开发(三)范围搜索
  5. 动态绘制CheckedTextView
  6. android 随手记-画虚线
  7. Android自定义视图二:用Canvas和Paint绘制折线图
  8. Android_VectorDrawable矢量图与SVG
  9. Android实现书籍翻页效果--扩展版

随机推荐

  1. [Android]当Activity启动模式为singleTas
  2. Android(安卓)LinearLayout 实现 高度动
  3. 碎纸机for android
  4. Android(安卓)Wi-Fi 设置country code的
  5. Android获取本机IP地址
  6. Android(安卓)文件浏览控件
  7. Android(安卓)内存泄露分析
  8. 第一行代码笔记 获取拍照照片和相册选取
  9. 禁止ScrollView内的控件改变之后自动滚动
  10. Android(安卓)动态切换全屏和非全屏模式