Android:使用shape制作素材
最近看到朋友制作的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>
</select>
蓝色带阴影按钮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>
Android:使用shape制作素材的更多相关文章
- Android使用shape制作圆形控件及添加弹跳动画
--------本来为作者原创,未经同意禁止转载 前言:我们在很多时候都需要在res/drawable文件夹下创建相应的xml文件来为控件添加一些样式效果,比如按钮按下时的按钮样式变化.或者指定按钮的 ...
- Android系列:res之shape制作
大家好,pls call me francis. nice to me you. 本文将介绍使用在Android中使用shape标签绘制drawable资源图片. 下面的代码是shap标签的基本使用情 ...
- Android:res之shape制作圆角、虚线、渐变
xml控件配置属性 android:background="@drawable/shape" 标签 corners ----------圆角gradient ----------渐 ...
- Android shape制作圆角、虚线、渐变
xml控件配置属性 android:background="@drawable/shape" 标签 corners ----------圆角 gradient ---------- ...
- Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)
Android XML shape 标签使用详解 一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...
- Android GradientDrawable(shape标签定义) 静态使用和动态使用(圆角,渐变实现)
Android GradientDrawable使用优势: 1. 快速实现一些基本图形(线,矩形,圆,椭圆,圆环) 2. 快速实现一些圆角,渐变,阴影等效果 3. 代替图片设置为View的背景 4. ...
- Android中shape属性详解
一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.x ...
- android用shape画虚线,怎么也不显示
一直以为android的shape能画直线.虚线.矩形,圆形等.画直线也就算了.用一个view设一下高度和颜色,就能够出来一条直线了.所以说这个对我来说常常不用,圆形是能够,看看我应用里的消息提 ...
- Android 使用shape定义不同控件的的颜色、背景色、边框色
Android 使用shape定义不同控件的的颜色.背景色.边框色 设置按钮的右边框和底边框颜色为红色,边框大小为3dp: 在drawable新建一个 buttonstyle.xml的文件,内容如下: ...
随机推荐
- Java中的BlockingQueue队列
BlockingQueue位于JDK5新增的concurrent包中,它很好地解决了多线程中,如何高效安全地“传输”数据的问题.通过这些高效并且线程安全的队列类,为我们快速搭建高质量的多线程程序带来极 ...
- Vue项目启动后首页URL带的#该怎么去掉?
修改router的mode为history就可以 const router = new VueRouter({mode: 'history', routes: [...]}) 实际修改后需要注意修改a ...
- C++ code:数值计算之辛普生(Simpson)法求解积分问题
- C++ one more time
写在前面:我们学习程序设计的方法先是模仿,然后举一反三.在自己的知识面还没有铺开到足够解决本领域的问题时,不要将精力过分集中于对全局无足轻重的地方!!! 以下参考钱能老师的<C++程序设计教程 ...
- Neural style transfer
网络风格迁移 作者:无用 本文通过学习吴恩达视频所做笔记 目录 简介 可视化卷积层 构建风格迁移网络 一.网络风格迁移简介 二.可视化卷积层 可视化深层卷积网络???这个问题我看过一篇文章,我会在后补 ...
- Fiddler抓包8-打断点(bpu)
前言 先给大家讲一则小故事,在我们很小的时候是没有手机的,那时候跟女神聊天都靠小纸条.某屌丝A男对隔壁小王的隔壁女神C倾慕已久,于是天天小纸条骚扰,无奈中间隔着一个小王,这样小王就负责传小纸条了.有一 ...
- python 全栈开发,Day6(is,小数据池,编码转换)
一.is a = 100 b = 100 print(a == b) print(a is b) 执行输出: TrueTrue 查看内存地址,使用id函数 print(id(a)) print(id( ...
- CSS3滚动条美化,CSS3滚动条皮肤
CSS3 -webkit-scrollbar滚动条皮肤美化实现,利用-webkit-scrollbar,-webkit-scrollbar-track,-webkit-scrollbar-thumb这 ...
- 【Java】 剑指offer(26) 树的子结构
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 输入两棵二叉树A和B,判断B是不是A的子结构. 思路 1)先对A树 ...
- 每天减一半。问多少天这个绳子会小于5米?进而得while和for的关系
一:前提 1.程序 2.结果 3.使用 for的条件只要>5 变化的条件是x/=2 4.进而使用while,得第二种方法 5.结果相同 二:结论 程序可以使用for的必将可以使用while. 其 ...