前言

最近看到朋友制作的Android APP使用了极少的图片,但是图形却极其丰富,问了之后得知是使用shape绘制的,有很多优点。

下面是我整理的一些素材:

预览

下面是图片预览:

代码

布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/s1"
android:padding="5dp"
android:text="@string/s1"
android:textColor="#fff"
android:textSize="16sp" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/s2"
android:padding="5dp"
android:text="@string/s2"
android:textColor="#ff9800"
android:textSize="16sp" /> <ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:background="@drawable/s3"
android:padding="10dp"
android:scaleType="fitXY"
android:src="@drawable/lsearch" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/s4"
android:padding="5dp"
android:text="@string/s4"
android:textColor="#fff"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/s5"
android:padding="5dp"
android:text="@string/s5"
android:textColor="#00bcd4"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/s6"
android:padding="5dp"
android:text="@string/s6"
android:textColor="#fff"
android:textSize="16sp" /> </LinearLayout>

shape文件

绿色标签s1.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#009688" />
<corners android:radius="8dp" />
</shape>

橙色标签s2.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#00000000" />
<corners android:radius="8dp" />
<stroke android:width="1dp" android:color="#ff9800" />
</shape>

蓝色圆形按钮s3.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#aa00bcd4" />
</shape>
</item> <item android:state_focused="true">
<shape android:shape="oval">
<solid android:color="#aa00bcd4" />
</shape>
</item> <item>
<shape android:shape="oval">
<solid android:color="#00bcd4" />
</shape>
</item> </selector>

蓝色按钮s4.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
<shape>
<solid android:color="#aa00bcd4" />
<corners android:radius="8dp" />
</shape>
</item> <item android:state_focused="true">
<shape>
<solid android:color="#aa00bcd4" />
<corners android:radius="8dp" />
</shape>
</item> <item>
<shape>
<solid android:color="#00bcd4" />
<corners android:radius="8dp" />
</shape>
</item> </selector>

蓝色边框按钮s5.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
<shape>
<solid android:color="#e3e3e3" />
<corners android:radius="8dp" />
<stroke android:width="1dp" android:color="#00bcd4" />
</shape>
</item> <item android:state_focused="true">
<shape>
<solid android:color="#e3e3e3" />
<corners android:radius="8dp" />
<stroke android:width="1dp" android:color="#00bcd4" />
</shape>
</item> <item>
<shape>
<solid android:color="#00000000" />
<corners android:radius="8dp" />
<stroke android:width="1dp" android:color="#00bcd4" />
</shape>
</item> </selector>

蓝色带阴影按钮s6.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
<layer-list>
<item android:top="3dp">
<shape>
<solid android:color="#00bcd4" />
<corners android:radius="8dp" />
</shape>
</item>
</layer-list>
</item> <item android:state_focused="true">
<layer-list>
<item android:top="3dp">
<shape>
<solid android:color="#00bcd4" />
<corners android:radius="8dp" />
</shape>
</item>
</layer-list>
</item> <item>
<layer-list>
<item>
<shape>
<solid android:color="#dddddd" />
<corners android:radius="8dp"/>
</shape>
</item>
<item android:bottom="3dp">
<shape>
<solid android:color="#00bcd4" />
<corners android:radius="8dp"/>
</shape>
</item>
</layer-list>
</item> </selector>

参考

谷歌官方文档

qiita.com

最新文章

  1. font-family字体总结
  2. 【SQL篇章--DATABASE/EVENTS】
  3. mvc导出excel 之 新
  4. form、iframe实现异步上传文件
  5. iOS-Debug
  6. Web知识总结
  7. Dedecms v5.7 最新注入分析
  8. SQL —— 视图
  9. &#39;String&#39; does not conform to protocol &#39;CollectionType&#39; Error in Swift 2.0
  10. Visual C++ 打印编程技术-编程基础-映射模式
  11. NOI2015 程序自动分析 prog
  12. Android中的一些小知识
  13. Asp.Net Core 轻松学-HttpClient的演进和避坑
  14. sql判断日期是否为当前季度
  15. H5_canvas与svg
  16. luogu1082 [NOIp2012]同余方程 (扩展欧几里得)
  17. [转]Mysql中的SQL优化与执行计划
  18. Three-js 创建第一个3D场景
  19. IDEA 开发环境中 调试Spark SQL及遇到问题解决办法
  20. 最小树形图(hdu4009)

热门文章

  1. Python List insert()方法详解
  2. python笔记九(迭代)
  3. Python3 OS 文件/目录方法
  4. Python3 注释
  5. AbstractQueuedSynchronizer 原理分析 - 独占/共享模式
  6. Android Design Support Library使用详解——TextInputLayout与TextInputEditText
  7. 整理的Java List Set Map是否有序,元素是否允许重复
  8. Unity3D各平台Application.xxxPath的路径
  9. Android源码解析——Toast
  10. Scala:数据类型和变量