android的兼容性真是一个不可忽略的问题,今天测试时发现使用xml定义Shape drawable在android 2.1上存在bug

  1. <SPANstyle="FONT-SIZE: 18px"><?xmlversion="1.0"encoding="UTF-8"?>
  2. <shapeandroid:shape="rectangle"
  3. xmlns:android="http://schemas.android.com/apk/res/android">
  4. <solidandroid:color="#319ED0"/>
  5. <corners
  6. android:bottomLeftRadius="0.0dip"
  7. android:bottomRightRadius="8.0dip"
  8. android:topLeftRadius="8.0dip"
  9. android:topRightRadius="0.0dip"/>
  10. </shape></SPAN>

把上面的xml定义作为Button的background时,在android 2.2和android 2.3都能正常显示圆角;但在android 2.1的真机和模拟器上均无法显示圆角

研读了一下android doc,发现这么一句话

  1. Note: Every corner must (initially) be provided a corner radius greater than 1, or else no corners are rounded. If you want specific corners to not be rounded, a work-around is to use android:radius to set a default corner radius greater than 1, but then override each and every corner with the values you really want, providing zero ("0dp") where you don't want rounded corners.

于是改为

  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <shapeandroid:shape="rectangle"
  3. xmlns:android="http://schemas.android.com/apk/res/android">
  4. <solidandroid:color="#319ED0"/>
  5. <corners
  6. android:radius="1dip"
  7. android:bottomLeftRadius="0dip"
  8. android:bottomRightRadius="8.0dip"
  9. android:topLeftRadius="8.0dip"
  10. android:topRightRadius="0dip"/>
  11. </shape>

一切正常

原来多年以前就有人提过这个bug了,高人给出了建议

  1. <cornersandroid:bottomRightRadius="0.1dp"
  2. android:bottomLeftRadius="7dip"
  3. android:topLeftRadius="7dip"
  4. android:topRightRadius="0.1dp"/>

使用很小的radius来到达一个近似与“方角”的效果,恩,很好的work around

android2.1中<shape>圆角的bug的更多相关文章

  1. Android中shape属性详解

    一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.x ...

  2. Android 之 Shape (圆角输入框)

    1 简介 本文主要介绍通过 shape 来设置 EditText 的圆角.   2 shape 的设置   shape_life_search.xml 放在 res/drawable 文件夹内 < ...

  3. Android UI(一)Layout 背景局部Shape圆角设计

    Jeff Lee blog:   http://www.cnblogs.com/Alandre/  (泥沙砖瓦浆木匠),retain the url when reproduced ! Thanks ...

  4. WPF中Polyline拐角的bug

    原文:WPF中Polyline拐角的bug       Polyline绘制折线在小角度(比如几度)的时候会出现不连续的现象,形成拐角的两条线段中有一段会超出,角度越小越明显.       问题如下图 ...

  5. 如何在html中做圆角矩形和 只有右边的"分隔线"

    这个网站满好的,可以常看看 css-matic中有几个很好的写css可视化的工具 其实做css 版式布局等都可以有工具的 推荐40个优秀的免费CSS工具 debugger正则表达式在线 其实是对(理论 ...

  6. CODESOFT中的圆角矩形的弧度该怎样设置?

      CODESOFT标签设计软件提供多种图形制作按钮,方便用户更为快捷的制作标签.其中就包括矩形,圆角矩形的快捷创建按钮.本文将介绍如何设置CODESOFT圆角矩形的弧度. 若有疑问可直接访问:htt ...

  7. li在IE中底部空行的BUG

    li在IE中底部空行的BUG 但是这次li在IE中底部出现的不是3像素而是一整条空白行,如图:HTML代码: <ul> <li><a href="#" ...

  8. 【IE6的疯狂之九】li在IE中底部空行的BUG

    曾经写过[IE6的疯狂之六]li在IE中底部3像素的BUG(增加浮动解决问题),原文地址:http://www.css88.com/archives/421: IE6 BUG大全: http://ww ...

  9. Excel日期中那个著名的bug

    一个软件中的bug能够持续多久?答案不一,大多数bug在软件测试阶段就已经被干掉,又有许多死在Preview阶段,抑或正式上线后不久被干掉,有些则伴随软件终生,直到下一代产品发布才寿终正寝,而Exce ...

随机推荐

  1. 原生nodejs 学习笔记2

    本章节学习流, 流的一个好处在于减少各种异步IO的回调地狱.IO操作遍及我们各种操作,比如数据库读写,文件读写, 文件转换压缩--别的不说,比如第一节,我们要将一个HTML文件返回浏览器,就涉及IO操 ...

  2. ibernate 配置数据库方言

          在开发hibernate的程序时,需要进行SessionFactory的配置,简单地说,也就是建立与数据库之间连接的配置,在hibernate中一般使用xml文件来进行配置,但是在该文件的 ...

  3. t检验,T Test (Student’s T-Test)

    1.什么是T test? t-test:比较数据的均值,告诉你这两者之间是否相同,并给出这种不同的显著性(即是否是因为偶然导致的不同) The t test (also called Student’ ...

  4. Ubuntu下Eclipse热键Ctrl+Alt+Up无效的解决

    原文链接 :http://rox.iteye.com/blog/875078 现在好多链接都打不开了, Ubuntu下一直用NetBeans开发,改了热键为Eclipse的,复制行不管用,一直认为是N ...

  5. padright padleft

    在 C# 中可以对字符串使用 PadLeft 和 PadRight 进行轻松地补位. PadLeft(int totalWidth, char paddingChar) //在字符串左边用 paddi ...

  6. jQuery源码解读一

    (function(window,undefined){...})(window); 这是一个典型的自执行的匿名函数. 为什么会有一个名为undefined的形参呢? undefined不是常量,可以 ...

  7. html标签的总结-重复

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  8. 利用委托机制处理.NET中的异常

    WinForm代码 private void button1_Click(object sender, EventArgs e) { try { Convert.ToInt32("abcd& ...

  9. Maven + spring + Mybatis + SpringMVC

    tomcat版本:apache-tomcat-7.0.70 一.新建一个maven的web项目 1.1.请勾选“Create a simple project”,创建一个简单的项目,这里不使用模板.也 ...

  10. jQuery 用$.param(json) 将 Json 转换为 Url queryString

    如: var params = { param1: 'bar', param2: 'foo' }; var queryString = $.param(params); // queryString ...