android初级学习之使用shape显示圆形

来源:互联网 发布:淘宝seo pdf 编辑:程序博客网 时间:2024/05/02 04:21

  今天项目中有个需求:TextView和ImageView需要显示为圆形。于是乎,就百度了一下,原来用shape可以轻松解决。下面就简单来说以下如何使用:
  其实也是相当于替换background属性的:
  首先在drawable下新建一个round.xml文件:

<?xml version="1.0" encoding="UTF-8"?><shape android:shape="oval"    xmlns:android="http://schemas.android.com/apk/res/android">    <!-- 描边 -->    <stroke android:width="1.0px" android:color="#ffa50303"/>    <!-- 填充-->    <solid android:color="#ffffffff"/></shape>

  然后在属性:android:background中引用该文件即可。
  

android:background="@drawable/round.xml"

文末附上shape一些常用属性值以便哪天需要用上:
Android中shape中的属性大全

0 0
原创粉丝点击