关于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. Codeforces Round #345 (Div. 2) E. Table Compression 并查集

    E. Table Compression 题目连接: http://www.codeforces.com/contest/651/problem/E Description Little Petya ...

  2. Xcode9出现错误safe area layout guide before ios 9 真正解决办法

    网上很多解决办法瞎扯淡,以讹传讹之势愈演愈烈. 正解是选中控制器,右边面板的Builds for 选择iOS9.0 and Later,如下图红框广为流传的错解是不勾选Use Safe Area La ...

  3. 如何通俗理解——>集群、负载均衡、分布式

    转自:周洲 (Julie) 在“高并发,海量数据,分布式,NoSql,云计算......”概念满天飞的年代,相信不少朋友都听说过甚至常与人提起“集群,负载均衡”等,但不是所有人都有机会真正接触到这些技 ...

  4. 【maven】pom.xml文件没错,但是项目有小红叉,Problems中可以看到错误:“Dynamic Web Module 3.0 requires Java 1.6 or newer.”

    解决方法: 1.将 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>m ...

  5. struts2安全漏洞

    1 背景 Struts2是apache项目下的一个web 框架,普遍应用于阿里巴巴.京东等互联网.政府.企业门户网站. 2 内容 在2013年6月底发布的Struts 2.3.15版本被曝出存在重要的 ...

  6. zend 环境

    js智能提示: 安装APTANA组件,最新3.0版本 安装地址:http://download.aptana.com/studio3/plugin/install Aptana 3 不能装 2 的 J ...

  7. 关于判断语句中如:while not xx: 或者:if not xx: 的含义及用法解析

    关于判断语句中如:while not xx: 或者:if not xx: 的含义及用法解析 name='' while not name: name=raw_input(u'请输入姓名:') prin ...

  8. SpringMVC防止XSS注入

    xss(Cross Site Scripting)注入就是,跨站脚本攻击,和sql注入类似的,在请求中添加恶意脚本,实现控制用户. XssHttpServletRequestWrappe.java 重 ...

  9. DevExpress 中 汉化包 汉化方法

    刚试了一下,直接把汉化包放在 Debug 目录下也是可以的.直接会汉化 第一步: 在Debug 下添加 zh-CN 汉化包(自行下载) 第二步: 在 Program.cs中添加以下代码 : Syste ...

  10. ivy由于sha1码不正确导致找不到模块(jar)的错误

    sbt设置jboss-interceptor-api-1.1作为依赖,但是找不到 [info] Resolving org.jboss.interceptor#jboss-interceptor-ap ...