发布于 2016-04-07 10:25:10 | 128 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


这篇文章主要介绍了Android编程实现圆角边框的方法,涉及Android针对样式布局的相关设置技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了Android编程实现圆角边框的方法。分享给大家供大家参考,具体如下:

设置边框圆角可以在drawable-mdpi目录里定义一个xml:


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/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="http://schemas.android.com/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程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务