手机四个角角上是圆的,算是带框还是不带???

Android布局实现圆角边框的两个方法-安卓教程-手机开发-壹聚教程网Android布局实现圆角边框的两个方法
很多Android应用喜欢用圆角边框布局,本文我们来介绍实现Android布局的两种方法,一个drawable-mdpi,一个用Shape。
方法一 使用 drawable-mdpi设置边框圆角可以在drawable-mdpi目录里定义一个xml: &?xml version=&1.0& encoding=&utf-8&?&&shape xmlns:android=&/apk/res/android&& &&&& &solid android:color=&#000000& /& &&&& &corners android:topLeftRadius=&10dp& &&&&&&&&&&&&&&&&&&& android:topRightRadius=&10dp& &&&&&&&&&&&&&&&& android:bottomRightRadius=&10dp& &&&&&&&&&&&&&&& android:bottomLeftRadius=&10dp&/& &&/shape&解释:solid的表示填充颜色,为了简单,这里用的是黑色。 而corners则是表示圆角,注意的是这里bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。 当然上面的效果也可以像下面一样设置,如下: &corners android:radius=&5dp& /&如果想引用这个xml,只需要@drawable/corners_bg.xml即可: android:background=&@drawable/corners_bg&最后main.xml: &?xml version=&1.0& encoding=&utf-8&?&&LinearLayout xmlns:android=&/apk/res/android&&& &android:orientation=&vertical& android:layout_width=&fill_parent&&& &android:layout_height=&fill_parent& android:background=&#FFFFFF&&&& &&RelativeLayout android:id=&@+id/login_div&&& &&& &android:layout_width=&fill_parent& android:layout_height=&150dip&&& &&& &android:padding=&15dip& android:layout_margin=&15dip&&& &&& &android:background=&@drawable/corners_bg&&&& &&/RelativeLayout&&/LinearLayout&方法二 Android使用 Shape 画边框线&1、布局&&& &?xml version=&1.0& encoding=&utf-8&?&&& &&&& &LinearLayout xmlns:Android=&/apk/res/android&&& &&&&&&&& android:layout_width=&fill_parent&&& &&&&&&&& android:layout_height=&fill_parent&&& &&&&&&&& android:background=&#FFFFFF&&& &&&&&&&& android:orientation=&vertical& &&& &&&&&&&& &&&&&&&& &!-- 表格布局 --&&& &&&&&&&& &TableLayout&& &&&&&&&&&&&& android:layout_width=&fill_parent&&& &&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&& android:padding=&10dip& &&& &&&&&&&&&&&& &!-- 表格布局:第一行 --&&& &&&&&&&&&&&& &TableRow&& &&&&&&&&&&&&&&&& android:layout_width=&fill_parent&&& &&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&& android:background=&@drawable/shape_top_corner_no_bottom_line&&& &&&&&&&&&&&&&&&& android:padding=&10dip& &&& &&&&&&&&&&&&&&&& &TextView&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_marginRight=&10dip&&& &&&&&&&&&&&&&&&&&&&& android:text=&姓名:& &&& &&&&&&&&&&&&&&&& &/TextView&&& &&&&&&&&&&&&&&&& &EditText&& &&&&&&&&&&&&&&&&&&&& android:id=&@+id/bankingYourNameEditText&&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_weight=&1&&& &&&&&&&&&&&&&&&&&&&& android:background=&@null&&& &&&&&&&&&&&&&&&&&&&& android:singleLine=&true& &&& &&&&&&&&&&&&&&&& &/EditText&&& &&&&&&&&&&&& &/TableRow&&& &&&&&&&&&&&& &!-- 表格布局:第二行 --&&& &&&&&&&&&&&& &TableRow&& &&&&&&&&&&&&&&&& android:layout_width=&fill_parent&&& &&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&& android:background=&@drawable/shape_no_corner_without_bottom&&& &&&&&&&&&&&&&&&& android:padding=&10dip& &&& &&&&&&&&&&&&&&&& &TextView&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_marginRight=&10dip&&& &&&&&&&&&&&&&&&&&&&& android:text=&联系电话:& &&& &&&&&&&&&&&&&&&& &/TextView&&& &&&&&&&&&&&&&&&& &EditText&& &&&&&&&&&&&&&&&&&&&& android:id=&@+id/bankingContactTelEditText&&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_weight=&1&&& &&&&&&&&&&&&&&&&&&&& android:background=&@null&&& &&&&&&&&&&&&&&&&&&&& android:inputType=&phone&&& &&&&&&&&&&&&&&&&&&&& android:singleLine=&true& &&& &&&&&&&&&&&&&&&& &/EditText&&& &&&&&&&&&&&& &/TableRow&&& &&&&&&&&&&&& &!-- 表格布局:第三行 --&&& &&&&&&&&&&&& &TableRow&& &&&&&&&&&&&&&&&& android:layout_width=&fill_parent&&& &&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&& android:background=&@drawable/shape_bottom_corner_no_top_line&&& &&&&&&&&&&&&&&&& android:padding=&10dip& &&& &&&&&&&&&&&&&&&& &TextView&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_marginRight=&10dip&&& &&&&&&&&&&&&&&&&&&&& android:text=&联系电话:& &&& &&&&&&&&&&&&&&&& &/TextView&&& &&&&&&&&&&&&&&&& &EditText&& &&&&&&&&&&&&&&&&&&&& android:id=&@+id/bankingContactTelEditText&&& &&&&&&&&&&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&&&&&&&&&& android:layout_gravity=&center_vertical&&& &&&&&&&&&&&&&&&&&&&& android:layout_weight=&1&&& &&&&&&&&&&&&&&&&&&&& android:background=&@null&&& &&&&&&&&&&&&&&&&&&&& android:inputType=&phone&&& &&&&&&&&&&&&&&&&&&&& android:singleLine=&true& &&& &&&&&&&&&&&&&&&& &/EditText&&& &&&&&&&&&&&& &/TableRow&&& &&&&&&&& &/TableLayout&&& &&&&&&&& &&&&&&&& &Button&& &&&&&&&&&&&& android:id=&@+id/button1&&& &&&&&&&&&&&& android:layout_width=&wrap_content&&& &&&&&&&&&&&& android:layout_height=&wrap_content&&& &&&&&&&&&&&& android:layout_gravity=&center&&& &&&&&&&&&&&& android:text=&Button& /&&& &&&&&&&& &&&& &/LinearLayout&&& &&&2、表格布局中每个TableRow表示一行,TableRow中的每个基本控件都是一列,这是一个三行两列的布局这里的表格背景是自定义的shape,下面分别看一下三个shape的代码。shape_top_corner_no_bottom_line.xml文件:顶部带圆角 白色背景 灰色边框 无下边框 长方体&&& &?xml version=&1.0& encoding=&UTF-8&?&&& &&&& &!-- 顶部带圆角 白色背景 灰色边框 无下边框 长方体 --&&& &&&& &layer-list xmlns:android=&/apk/res/android&&&& &&&&&&&& &item&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &corners android:topLeftRadius=&10dp& android:topRightRadius=&10dp&&& &&&&&&&&&&&&&&&&&&&& android:bottomRightRadius=&0.1dp& android:bottomLeftRadius=&0.1dp& /&&& &&&&&&&&&&&&&&&& &stroke android:width=&1dp& android:color=&#ffa8abad& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&&&&&& &item android:top=&1dp& android:left=&1dp& android:right=&1dp&&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &corners android:topLeftRadius=&10dp& android:topRightRadius=&10dp&&& &&&&&&&&&&&&&&&&&&&& android:bottomRightRadius=&0.1dp& android:bottomLeftRadius=&0.1dp& /&&& &&&&&&&&&&&&&&&& &stroke android:width=&1dp& android:color=&#ffffffff& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&& &/layer-list&&& &&3、shape_no_corner_without_bottom.xml文件:不带圆角 白色背景 灰色边框 无下边框 长方体&&& &?xml version=&1.0& encoding=&UTF-8&?&&& &&&& &!-- 不带圆角 白色背景 灰色边框 无下边框 长方体 --&&& &&&& &layer-list xmlns:android=&/apk/res/android& &&& &&&&&&&& &item&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &stroke&& &&&&&&&&&&&&&&&&&&&& android:width=&1dp&&& &&&&&&&&&&&&&&&&&&&& android:color=&#ffa8abad& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&&&&&& &item&& &&&&&&&&&&&& android:left=&1dp&&& &&&&&&&&&&&& android:right=&1dp&&& &&&&&&&&&&&& android:top=&1dp&&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &stroke&& &&&&&&&&&&&&&&&&&&&& android:width=&1dp&&& &&&&&&&&&&&&&&&&&&&& android:color=&#ffffffff& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&& &/layer-list&&& &&4、shape_bottom_corner_no_top_line.xml文件:底部圆角 白色背景 灰色边框 长方体&&& &?xml version=&1.0& encoding=&UTF-8&?&&& &&&& &!-- 底部圆角 白色背景 灰色边框 长方体 --&&& &&&& &layer-list xmlns:android=&/apk/res/android&&&& &&&&&&&& &item&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &corners android:topLeftRadius=&0.1dp& android:topRightRadius=&0.1dp&&& &&&&&&&&&&&&&&&&&&&& android:bottomRightRadius=&10dp& android:bottomLeftRadius=&10dp& /&&& &&&&&&&&&&&&&&&& &stroke android:width=&1dp& android:color=&#ffa8abad& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&&&&&& &item android:top=&1dp& android:bottom=&1dp& android:left=&1dp& android:right=&1dp&&&& &&&&&&&&&&&& &shape&&& &&&&&&&&&&&&&&&& &solid android:color=&#FFFFFF& /&&& &&&&&&&&&&&&&&&& &corners android:topLeftRadius=&0.1dp& android:topRightRadius=&0.1dp&&& &&&&&&&&&&&&&&&&&&&& android:bottomRightRadius=&10dp& android:bottomLeftRadius=&10dp& /&&& &&&&&&&&&&&&&&&& &stroke android:width=&1dp& android:color=&#ffffffff& /&&& &&&&&&&&&&&& &/shape&&& &&&&&&&& &/item&&& &&&& &/layer-list&& &&5、说明:&&&& shape_top_corner_no_bottom_line.xml&&&& shape_no_corner_without_bottom.xml&&&& shape_bottom_corner_no_top_line.xml &&&& 以上三个文件都存放在 drawable 中。&6、效果图查看附件。
上一页: &&&&&下一页:相关内容请问怎样把照片四个角成圆边的,是PS做的,还是有什么边框制作的软? - 爱问知识人
(window.slotbydup=window.slotbydup || []).push({
id: '2491531',
container: s,
size: '150,90',
display: 'inlay-fix'
请问怎样把照片四个角成圆边的
,急切想知道,另外,照片外的的黑框也是自己PS上去的吗?谢谢了!祝好!
亲,小丫是用PS做的,不过,其他的软件也可以处理成圆角的。照片外的黑框不是PS上去的,是用代码加上去滴。呵呵。
亲,小丫是用PS做的,不过,其他的软件也可以处理成圆角的。照片外的黑框不是PS上去的,是用代码加上去滴。呵呵。
1.先使用美图秀秀打开一张照片,选择“边框”菜单下的“简单边框”
2.点击“简单边框”之后,大家就可以在界面右侧选择喜欢的边框效果了。点击一个模版进入到编辑框中...
给你一个图片在线处理地址:
功能很多,可以给图片加水印.调整尺寸.加边框等.很方便的.处理后再
保存到电脑里.再上传到博客中
请看附件是不是您想要的结果。
祝您成功!
大家还关注

我要回帖

更多关于 android圆角边框 的文章

 

随机推荐