xml布局内容总结(三)--Android
关于xml中经经常使用到边框及边框效果,在此进行一下总结。
3.border(边框及边框效果)
(1)直角边框线
<LinearLayout
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:orientation="vertical"
android:background="@drawable/border_c"
>
</LinearLayout>
border_c.xml
<?
xml version="1.0" encoding="utf-8"?
>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 填充颜色 -->
<solid android:color="@color/listitem_green" />
<!-- 边框宽度。颜色 -->
<stroke
android:width="0.1dp"
android:color="@color/black" />
<!-- 4个角度的弧度设置 -->
<corners
android:topLeftRadius="0.0dip"
android:topRightRadius="0.0dip"
android:bottomLeftRadius="0.0dip"
android:bottomRightRadius="0.0dip"
/>
</shape>
(2)圆角边框线
<LinearLayout
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:orientation="vertical"
android:background="@drawable/border_s"
>
</LinearLayout>
border_s.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 填充颜色 -->
<solid android:color="@color/yellow" />
<!-- 边框宽度,颜色 -->
<stroke
android:width="0.1dp"
android:color="@color/black" />
<!-- 4个角度的弧度设置 -->
<corners
android:topLeftRadius="10.0dip"
android:topRightRadius="10.0dip"
android:bottomLeftRadius="10.0dip"
android:bottomRightRadius="10.0dip"
/>
</shape>
(3)横线,竖线
<TextView
android:layout_width="200dp"
android:layout_height="0.5dp"
android:background="@color/black"
/>
<TextView
android:layout_marginTop="10dp"
android:layout_width="0.5dp"
android:layout_height="50dp"
android:background="@color/black"
/>
(4)button效果
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/btn_style_green"
android:text="Button"
android:textColor="@color/white"
/>
btn_style_green.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_green_bg" android:state_pressed="true"/>
<item android:drawable="@drawable/button_blue_bg" android:state_focused="false" android:state_pressed="false"/>
</selector>
button_green_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/green" />
<stroke android:width="0.5dip" android:color="@color/black" />
<corners android:topLeftRadius="5.0dip" android:topRightRadius="5.0dip" android:bottomLeftRadius="5.0dip" android:bottomRightRadius="5.0dip" />
</shape>
button_blue_bg.xml
<?
xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/blue" />
<stroke android:width="0.5dip" android:color="@color/black" />
<corners android:topLeftRadius="5.0dip" android:topRightRadius="5.0dip" android:bottomLeftRadius="5.0dip" android:bottomRightRadius="5.0dip" />
</shape>
正常状态:
点击:
xml布局内容总结(三)--Android的更多相关文章
- xml布局内容总结(一)--Android
关于安卓项目中xml的使用非常多.为了达到一些好的UI效果.须要对xml比較熟练.会使用非常多的小技巧,本人准备对这些小技巧进行整理和总结,希望进行分享和交流. 关于weight的使用,因为weigh ...
- xml布局内容总结(四)--Android
(1)对于xml编写界面较复杂的情况下,使用include会使得编写和查看更清楚 <LinearLayout android:layout_width="mat ...
- 通过在xml布局文件中设置android:onClick=""来实现组件单击事件
在布局中出现android:onClick=""语句: <Button android:id="@+id/call_button" android:onC ...
- android xml布局文件属性说明
android xml布局文件属性说明 [摘]android xml布局文件属性说明 LinearLayout和RelativeLayout 共有属性:java代码中通过btn1关联次控件androi ...
- android 开发 使用自定义布局实现标题栏复用(标题栏内容自定义:使用代码实现和xml布局自定义属性2种办法实现)
在个人学习的情况下可能很少使用自定义布局去实现大量复用的情况下,但是在一个开发工作的环境下就会使用到大量复用的自定义控件. 实现思维: 1.写一个xml的布局,用于标题栏的样式,并且添加在标题栏中你想 ...
- Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析
转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PAREN ...
- Android中点击按钮获取string.xml中内容并弹窗提示
场景 AndroidStudio跑起来第一个App时新手遇到的那些坑: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103797 ...
- Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析
在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever yo ...
- Android开发 ---xml布局元素
1.android:orientation="vertical/horizontal" vertical为垂直布局, horizontal为水平布局 2.android:layou ...
随机推荐
- HTTP模块理解(二)
这是我在写,用express+ajax+swig来做一个简单的应用的时候,遇到的问题.还是不太理解http模块. 后来在网上看到云栖社区的一篇<Node.js之HTTP请求与响应>,这里做 ...
- MYSQL5上运行多个实例
date 20131005参考http://chenzehe.iteye.com/blog/1266260官方文档 http://dev.mysql.com/doc/refman/5.1/zh/dat ...
- CentOS 6.9配置网卡IP/网关/DNS命令详细介绍及一些常用网络配置命令(转)
一.IP 即时生效(重启后失效): ifconfig eth0 192.168.1.102 netmask 255.255.255.0 //添加IP地址 route add default gw 19 ...
- svn安装和配置
安装svn 参考http://blog.csdn.net/dl425134845/article/details/41978541 系统版本 uname -a # 查看内核/操作系统/CPU信息 he ...
- Android内存优化3 了解java GC 垃圾回收机制1
开篇废话 如果我们想要进行内存优化的工作,还是需要了解一下,但这一块的知识属于纯理论的,有可能看起来会有点枯燥,我尽量把这一篇的内容按照一定的逻辑来走一遍.首先,我们为什么要学习垃圾回收的机制,我大概 ...
- PostgreSQL配置文件--其他
9 CLIENT CONNECTION DEFAULTS 9.1 Statement Behavior 9.1.1 search_path 字符型 默认:search_path = '"$u ...
- Mybatis数据库操作的返回值
mybatis配置 <!-- 配置mybatis --> <bean id="sqlSessionFactory" class="org.mybatis ...
- sonar如何添加自定义JAVA规则
参考: 1.https://segmentfault.com/a/1190000008659108 2.https://docs.sonarqube.org/display/DEV/Adding+Co ...
- ylbtech-LanguageSamples-OLEDB
ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-OLEDB 1.A,示例(Sample) 返回顶部 “OLE DB”示例 本示例演示了如 ...
- Google Chrome插件开发-Context Menus
本节主要介绍如何在Google Chrome浏览器web页面上点击右键弹出自定义菜单,即如何使用谷歌Context Menus API接口.上节已经把主要流程介绍了,这节就直接上代码,代码都是官方例子 ...