关于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的更多相关文章

  1. xml布局内容总结(一)--Android

    关于安卓项目中xml的使用非常多.为了达到一些好的UI效果.须要对xml比較熟练.会使用非常多的小技巧,本人准备对这些小技巧进行整理和总结,希望进行分享和交流. 关于weight的使用,因为weigh ...

  2. xml布局内容总结(四)--Android

    (1)对于xml编写界面较复杂的情况下,使用include会使得编写和查看更清楚 <LinearLayout             android:layout_width="mat ...

  3. 通过在xml布局文件中设置android:onClick=""来实现组件单击事件

    在布局中出现android:onClick=""语句: <Button android:id="@+id/call_button" android:onC ...

  4. android xml布局文件属性说明

    android xml布局文件属性说明 [摘]android xml布局文件属性说明 LinearLayout和RelativeLayout 共有属性:java代码中通过btn1关联次控件androi ...

  5. android 开发 使用自定义布局实现标题栏复用(标题栏内容自定义:使用代码实现和xml布局自定义属性2种办法实现)

    在个人学习的情况下可能很少使用自定义布局去实现大量复用的情况下,但是在一个开发工作的环境下就会使用到大量复用的自定义控件. 实现思维: 1.写一个xml的布局,用于标题栏的样式,并且添加在标题栏中你想 ...

  6. Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析

    转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PAREN ...

  7. Android中点击按钮获取string.xml中内容并弹窗提示

    场景 AndroidStudio跑起来第一个App时新手遇到的那些坑: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103797 ...

  8. Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析

    在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever yo ...

  9. Android开发 ---xml布局元素

    1.android:orientation="vertical/horizontal" vertical为垂直布局, horizontal为水平布局 2.android:layou ...

随机推荐

  1. Java编程思想学习(一)----对象导论中多态的理解

    1.1抽象过程 1)万物皆对象. 2)程序是对象的集合,他们通过发送消息来告知彼此所要求做的. 3)每个对象都有自己的由其他对象所构成的存储. 4)每个对象都拥有其类型. 5)某一特定类型的所有对象都 ...

  2. ERROR 1044: Access denied for user: 'songyan' to database 'yikexiao' 的错误。

    问题描述:新买的服务器,刚安装了mysql,创建了一个用户,也忘记了给他分配了什么权限,今天在建库的时候出现了这个问题. 出错原因:度娘告诉我是因为songyan用户没有建库的权限报的错. 解决: ( ...

  3. python使用sqlite示例

    SQLite是一种嵌入式数据库,它的数据库就是一个文件.Python就内置了SQLite3,所以,在Python中使用SQLite,不需要安装任何东西,直接使用. 操作关系数据库,首先需要连接到数据库 ...

  4. nor flash 和nand flash 的区别

    ROM和RAM指的都是半导体存储器,ROM是Read Only Memory的缩写,RAM是Random Access Memory的缩写.ROM在系统停止供电的时候仍然可以保持数据,而RAM通常都是 ...

  5. java多线程处理导入数据拆分List集合 同步处理插入数据

    原文:https://www.2cto.com/kf/201612/581174.html import org.apache.log4j.Logger; import org.apache.poi. ...

  6. 统计中的f检验和t检验的区别

    参考:http://emuch.net/html/201102/2841741.html 首先是目的不同.F检验用于比较两种分析方法是否存在显著差异(单边检验)或者两种方法紧密度是否存在差异(双边检验 ...

  7. NPD南京炮苑电子技术研究所----NPD治疗仪

    NPD南京炮苑电子技术研究所有限公司:    http://www.npd365.com/ 研发药物离子导入和中医定向透药技术.   南京炮苑玉古康2号NPD系列专用中医定向透药治疗仪腰颈椎疼痛贴 N ...

  8. Anaconda安装Graphviz, mac下Graphviz安装, pcharm中调用pycharm, Graphviz典型例子

    mac下的Graphviz安装及使用 2017年10月13日 13:30:07 阅读数:7495 一.安装 Graphviz http://www.graphviz.org/ mac用户建议直接用ho ...

  9. 三分钟教你学Git(十八) - 重写历史

    git filter-branch 同意你使用一个单一命令来大范围地更改历史.所以这个命令要慎用. 1假如你想对全部的commits删除一个文件. git filter-branch --tree-f ...

  10. iOS:进度条控件的详细使用

    进度条控件:UIProcessView:UIView   功能:顾名思义,用来显示下载进度或者传输数据进度.   属性: @property(nonatomic) UIProgressViewStyl ...