关于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. [BZOJ1004](HNOI 2008) Cards

    Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目 前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有多少种染色方案,Sun很快就给出了答案.进一步,小春要求染出Sr张 ...

  2. 2016.4.9 NOI codevs动态规划专练

    1.NOI 最大子矩阵 1:最大子矩阵 总时间限制:  1000ms 内存限制:  65536kB 描述 已知矩阵的大小定义为矩阵中所有元素的和.给定一个矩阵,你的任务是找到最大的非空(大小至少是1 ...

  3. PHP与Web页面的交互

    1.form表单默认情况下提交数据的方式为get方式. 2.PHP脚本用来处理表单数据的预定义变量是$_GET,$_POST(区分大小写) 代码示例:(特别注意复选框属性name的时候加数组) sim ...

  4. [转]spring4.x注解概述

    1. 背景 注解可以减少代码的开发量,spring提供了丰富的注解功能,因项目中用到不少注解,因此下定决心,经spring4.x中涉及到的注解罗列出来,供查询使用. 2. spring注解图     ...

  5. Educational Codeforces Round 9 C. The Smallest String Concatenation 排序

    C. The Smallest String Concatenation 题目连接: http://www.codeforces.com/contest/632/problem/C Descripti ...

  6. 打造百度网盘备份利器:自动备份Linux VPS文件和多线程下载百度网盘资源

    前一段时间国内的各大网盘百度云盘,金山快盘,360云盘,华为网盘为争夺用户上演空间容量博弈,网盘商们还固执地以为中国的网民都不懂网络技术,可以像某公司那样用一些数字的手段来忽悠用户,参与到网盘商的数字 ...

  7. selector简介

    最近在学习java NIO,发现java nio selector 相对 channel ,buffer 这两个概念是比较难理解的 ,把学习理解的东西以文字的东西记录下来,就像从内存落地到硬盘,把内存 ...

  8. iOS- dispatch_semaphore和NSOperationQueue并发

    并发:同一个时间内运行多个任务.又叫共行性,是指处理多个同时性活动的能力. 并行:是指两个并发的任务同时发生. 并发不一定并行,并发不一定要同时发生. 举个例子: 有两个快递分别要送到目的地,有以下两 ...

  9. 如何在form初始化时自动隐藏FOLDER列

    方法1:直接设定PROMPT列和数据列ITEM的VISIBLE属性为No 方法2:在WHEN-NEW-FORM-INSTANCE触发器里: l_old_itm := :system.cursor_it ...

  10. 动态jdk启动项目

    昨天遇到,服务器安装jdk1.7,但是springboot项目用jdk1.8编译的,所以需要指定jdk版本启动: nohup /root/jdk1.8.0_11/bin/java -jar /root ...