关于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. Problem B: 判断回文字符串

    #include<stdio.h> #include<string.h> int huiwen(char *str) //定义回文函数 { //char ch[100]; in ...

  2. 十二. 网络与数据库编程1.IP地址和InetAddress类

    Java语言的优势之一是Java程序能访问网络资源.Java提供一系列的类支持Java程序访问网络资源. TCP/IP协议和IP地址 为了进行网络通信,通信双方必须遵守通信协议.目前最广泛使用的是TC ...

  3. PHP stream 学习笔记一(同步阻塞 IO 模型)

    原文http://blog.csdn.net/shagoo/article/details/6396089 [root@localhost php]# vi server_one.php <?p ...

  4. Codeforces Round #127 (Div. 1) B. Guess That Car! 扫描线

    B. Guess That Car! 题目连接: http://codeforces.com/contest/201/problem/B Description A widely known amon ...

  5. 基于tiny4412的Linux内核移植 -- eMMC驱动移植(六)

    作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...

  6. 使用Busybox制作CRAMFS文件系统成功

    转:http://www.360doc.com/content/11/1013/22/7775902_155877501.shtml 这几天在使用Busybox制作FS2410开发板的CRAMFS文件 ...

  7. Java并发包之闭锁/栅栏/信号量

    二.同步工具类详解 1.Semaphore信号量:跟锁机制存在一定的相似性,semaphore也是一种锁机制,所不同的是,reentrantLock是只允许一个线程获得锁,而信号量持有多个许可(per ...

  8. node.js+mysql增删查改

    数据库和表: -- -- 数据库: `test` -- -- -------------------------------------------------------- -- -- 表的结构 ` ...

  9. 简单nginx+tomca负载均衡

    Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性: 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,这点使 ...

  10. screen space shadowmap unity

    unity用到了screen space shadow map 1.camera 在light pos 生成depth1 2.screen space depth2 3.根据depth1 depth2 ...