关于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. 浙南联合训练赛 D - Broken Clock

    You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM fo ...

  2. Problem C: 输入10个数,根据提示进行从小到大输出或从大到小输出

    #include<stdio.h> int main() { char ch; ]; while(scanf("%c",&ch)!=EOF) { int i,j ...

  3. 【MySQL笔记】启动弹窗问题,unable to connect to remote host. catalog download has failed.

    安装完MySQL之后,它每天凌晨启动一个Intaller任务,甚是烦人:   这是一个Windows的计划服务,在这里删除即可,开始/附件/系统工具/任务计划程序,把mysql的定时任务计划取消/删除 ...

  4. [转]Java程序员从笨鸟到菜鸟之(八十三)细谈Spring(十二)OpenSessionInView详解及用法

    首先我们来看一下什么是OpenSessionInView?    在hibernate中使用load方法时,并未把数据真正获取时就关闭了session,当我们真正想获取数据时会迫使load加载数据,而 ...

  5. Linux使用pyVLfeat库做Dense sift提示段错误(segmentation fault)详细分析

    pyVLfeat是著名的图像处理库VLFeat在python上的接口包.在linux环境下使用该库提示“段错误”.百度后得知: 所谓的段错误就是指访问的内存超出了系统所给这个程序的内存空间 意思其实就 ...

  6. json字符串生成C#实体类的工具

    转载:http://www.cnblogs.com/finesite/archive/2011/07/31/2122984.html json作为互联网上轻量便捷的数据传输格式,越来越受到重视.但在服 ...

  7. ECSHOP中transport.js和jquery冲突的解决方法

    jQuery 和global.js 冲突 百度和google多次,根据网上的大多数建议和自己测试,解决办法如下:删除global.js 或者global.js 文件的10-13行屏蔽//Object. ...

  8. Node.js中的express框架获取参数

    express获取参数有三种方法: req.query  适合 http://localhost:3000/form?num=8888 req.body   适合http://localhost:30 ...

  9. python笔记4-遍历文件夹目录os.walk()

    前言 如何遍历查找出某个文件夹内所有的子文件呢?并且找出某个后缀的所有文件 walk功能简介 1.os.walk() 方法用于通过在目录树种游走输出在目录中的文件名,向上或者向下. 2.walk()方 ...

  10. 万里长征第二步——django个人博客(第三步 —— 设置一些全局变量)

    可以将一些全局变量设置在settingg.py里 #网站的基本信息配置 SITE_NAME = 'John的个人博客' SITE_DESC = '专注学习Python开发,欢迎和大家交流' WEIBO ...