android Shape Drawable美化圆角图形

ShareDrawable资源

shareDrawable资料用于定义一个基本的集合图形,它在xml资源文件中,使用<shap.../>根元素定义,使用android:shape属性定义集合图形类形。shareDrawable可以定义矩形,圆形,椭圆形,线形等几种图形。

下面举个例子:

在shape_textview.xml文件中:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:shape="rectangle" >
 4     <gradient android:startColor="#FFFF0000"
 5         android:endColor="#80FF00FF"
 6         android:angle="45"/>
 7
 8     <padding android:left="7dp"
 9         android:top="7dp"
10         android:right="7dp"
11         android:bottom="7dp"/>
12     <corners android:radius="8dp"/>
13 </shape>

在main_activity.xml文件中:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context=".MainActivity" >
10
11     <TextView
12         android:layout_width="fill_parent"
13         android:layout_height="wrap_content"
14         android:background="@drawable/shape_textview"
15         android:text="@string/hello_world" />
16
17 </RelativeLayout>

运行结果:

时间: 2024-08-01 23:31:51

android Shape Drawable美化圆角图形的相关文章

Android Shape自定义纯色圆角按钮

版权声明:分享技术,传播快乐.如果本博客对你有帮助,请在我的博客首页为我打赏吧! 在Android开发中,为响应美化应用中控件的效果,使用Shape定义图形效果,可以解决图片过多的问题. 首先看一下效果图: 整个页面布局为: 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res

android shape图形优化Button效果

android shape可以让我们通过定义xml文件的方式创建图形,当然只能实现一些比较简单的图形(圆形,矩形,椭圆,线段),但是已经相当不错了,通过shape创建的图形作为控件的背景已经基本可以满足我的简单需求了,而且通过shape创建的图形可以适配各种屏幕. 下面就用shape定义的图形来优化Button的整体效果. 定义主布局文件activity_main.xml: 1 <RelativeLayout xmlns:android="http://schemas.android.co

Android Drawable - Shape Drawable使用详解(附图)

TIPS shape图形 –简单介绍 shape图形 –如何画? shape图形 –参数详细解析 shape图形 –如何用? shape图形 –实际开发应用场景 shape图形简单介绍 用xml实现一些形状图形, 或则颜色渐变效果, 相比PNG图片, 占用空间更小; 相比自定义View, 实现起来更加简单 怎么画? 在res/drawable/目录下建一个XML资源文件 Shape图片语法相对复杂, 下面是一个总结性的注释, 涵盖了大部分的参数,属性, 建议先跳过这段, 回头再看 [java] 

Android中android.graphics下面的绘制图形类Canvas,Paint,Bitmap,Drawable

1.概念区别: 很多网友刚刚开始学习Android平台,对于Drawable.Bitmap.Canvas和Paint它们之间的概念不是很清楚, 其实它们除了Drawable外早在Sun的J2ME中就已经出现了,但是在Android平台中,Bitmap.Canvas相关的都有所变化. 首先让我们理解下Android平台中的显示类是View,但是还提供了底层图形类android.graphics,今天所说的这些均为graphics底层图形接口. Bitmap - 称作位图,一般位图的文件格式后缀为b

第六章:Android的Drawable

Drawable表示的是一种可以在Canvas上进行绘制的抽象的概念. 6.1 Drawable简介 Drawable常被用来作为View的背景使用. Drawable一般都是通过XML来定义的. Drawable是一个抽象类,它是所有Drawable对象的基类,每个具体的Drawable都是它的子类. Drawable的内部宽/高这个参数比较重要,通过getIntrinsicWidth和getIntrinsicHeight这两个方法可以获取到它们. 6.2 Drawable的分类 6.2.1

android中Drawable方法详解

1. BitmapDrawable相关方法: 新建在drawable目录下面,示例如下: <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:antialias="true" android:dither="true" android:filter="true" android:gravity="center&qu

android shape.xml 属性详解

转载源:http://blog.csdn.net/harvic880925/article/details/41850723 一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml 内容是这样的:(先不需要理解,先看shape怎么用) [html] view plaincopy <?xml version="1.0" encodin

玩转Android之Drawable的使用

Drawable天天用,可你是否对Drawable家族有一个完整的认知?今天我们就来系统的学习一下Drawable的使用. 1.概述 用过Drawable的筒子都知道Drawable有很多种,有的时候Drawable是一张图片,有的时候Drawable是我们通过颜色构造出来的某种图形.最常见的自己构造的Drawable图形莫过于ShapeDrawable,我们在开发中可能经常需要自己绘制一个矩形.圆形.椭圆等等各种各样的图形.一般来说,Drawable并没大小的概念(虽然可以通过getIntri

Android Shape 形状

Shape继承体系: Shape (android.graphics.drawable.shapes) ----PathShape (android.graphics.drawable.shapes) ----RectShape (android.graphics.drawable.shapes) --------ArcShape (android.graphics.drawable.shapes) --------OvalShape (android.graphics.drawable.sha