安卓圆角矩形的定义

在drawable文件夹下,定义corner.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="#FF8C69"></solid> <!-- 线的宽度,颜色灰色 -->
<stroke android:width="1dp" android:color="#D5D5D5"></stroke> <!-- 矩形的圆角半径 -->
<corners android:radius="10dp" /> </shape>

具体使用

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" > <ImageView
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/b"
android:padding="0dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1"
>
<LinearLayout
android:id="@+id/l1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="3dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="@drawable/corner"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="二手市场" />
</LinearLayout> <LinearLayout
android:id="@+id/l2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="@drawable/corner2"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="失物招领" />
</LinearLayout>
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/l3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_margin="3dp"
android:layout_weight="1"
android:background="@drawable/corner3"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="寻物启事" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="@drawable/corner4"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="表白墙" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal"
>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="@drawable/corner5"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="生活查询" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="@drawable/corner6"
android:gravity="center"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="校园查询" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout>

参考链接

android 怎么画一个圆角矩形_百度知道

效果如下

Android之圆角矩形的更多相关文章

  1. Android自定义圆角矩形进度条2

    效果图: 或 方法讲解: (1)invalidate()方法 invalidate()是用来刷新View的,必须是在UI线程中进行工作.比如在修改某个view的显示时, 调用invalidate()才 ...

  2. [BOT] 一种android中实现“圆角矩形”的方法

    内容简介 文章介绍ImageView(方法也可以应用到其它View)圆角矩形(包括圆形)的一种实现方式,四个角可以分别指定为圆角.思路是利用"Xfermode + Path"来进行 ...

  3. Android中实现圆角矩形及半透明效果。

    注:本文由Colin撰写,版权所有!转载请注明原文地址,谢谢合作! 在做Android开发时,我们为了美观,有时候需要使用圆角矩形,或半透明之类的效果,在网页设计中很容易实现.但在Android开发中 ...

  4. Android圆角矩形创建工具RoundRect类

    用于把普通图片转换为圆角图像的工具类RoundRect类(复制即可使用): import android.content.Context; import android.graphics.Bitmap ...

  5. Android利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形) .

    1.首先说一下canvas类: Class Overview The Canvas class holds the "draw" calls. To draw something, ...

  6. Android开发之自定义圆角矩形图片ImageView的实现

    android中的ImageView只能显示矩形的图片,这样一来不能满足我们其他的需求,比如要显示圆角矩形的图片,这个时候,我们就需要自定义ImageView了,其原理就是首先获取到图片的Bitmap ...

  7. Android中绘制圆角矩形图片及任意形状图片

    圆角矩形图片在苹果的产品中很流行,相比于普通的矩形,很多人都喜欢圆角矩形的图片,因为它避开了直角的生硬,带来更好的用户体验,下面是几个设计的例子: 下面在Android中实现将普通的矩形图片绘制成圆角 ...

  8. Android开发之自定义圆角矩形图片ImageView的实现 - Jamy Cai

    android中的ImageView只能显示矩形的图片,这样一来不能满足我们其他的需求,比如要显示圆角矩形的图片,这个时候,我们就需要自定义ImageView了,其原理就是首先获取到图片的Bitmap ...

  9. Android 自定义的圆角矩形ImageView 工具类

    上图看效果 自定义圆角矩形ImageView工具类 package com.wechaotou.utils; import android.content.Context; import androi ...

随机推荐

  1. android jni

    1, java.lang.UnsatisfiedLinkError: Couldn't load xxxxx: findLibrary returned null 当 apk 是被放到 /system ...

  2. 用多态来实现U盘,Mp3,移动硬盘和电脑的对接,读取写入数据。

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. MIM协议与Base64编码

    MIME Protocol 1. MIME的全称是"Multipurpose Internet Mail Extensions",中译为"多用途互联网邮件扩展" ...

  4. linux 软件安装

    A:RPM包,这种软件包就像windows的EXE安装文件一样,各种文件已经编译好,并打了包,哪个文件该放到哪个文件夹,都指定好了,安装非常方便,在图形界面里你只需要双击就能自动安装,如果在命令行模式 ...

  5. SqlServer Link 链接服务器的使用

    --创建linked exec sp_addlinkedserver 'a','','SQLNCLI','your ipaddress' --登陆linked exec sp_addlinkedsrv ...

  6. java随机生成简体中文取指定长度随机简体中文实用方法

    /**     * 获取指定长度随机简体中文     * @param len int     * @return String     */    public static String getR ...

  7. jQuery1.11源码分析(4)-----Sizzle工厂函数[原创]

    在用前两篇讲述完正则表达式.初始化.特性检测之后,终于到了我们的正餐——Sizzle工厂函数! Sizzle工厂函数有四个参数, selector:选择符 context:查找上下文 results: ...

  8. C++编程思想重点笔记(上)

    C和C++指针的最重要的区别在于:C++是一种类型要求更强的语言.就void *而言,这一点表现得更加突出.C虽然不允许随便地把一个类型的指针指派给另一个类型,但允许通过void *来实现.例如: b ...

  9. dedecms后台批量替换文章中的关键词

    DEDECMS怎么样能快捷或者批量修改网站所有文章的超链接和锚文本,超链和所有关键词锚文本的链接需要修改? dedecms后台批量替换文章中的关键词

  10. Windows 的 AD 域寄生于 Linux 机器

    导读 对于帐户统一管理系统或软件来说,在 Linux 下你可能知道 NIS.OpenLDAP.samba 或者是 RedHat.IBM 的产品,在 Windows 下当然就是最出名的活动目录 (AD) ...