android View使用shape作为背景不能指定单边圆角的xml
发布日期:2021-09-27 14:12:58 浏览次数:2 分类:技术文章

本文共 952 字,大约阅读时间需要 3 分钟。

在使用shape作为背景的时候,代码如下:

 

[html] 
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.     <corners android:topLeftRadius="30dp" android:bottomLeftRadius="30dp"  
  4.         android:topRightRadius="0dp" android:bottomRightRadius="0dp"/>  
  5.     <solid android:color="#ff0000"/>  
  6. </shape>  
在android3.0以上显示正常如下:

 

但是在android3.0以下,比如android2.3.3结果如下:

这显然不符合我们的要去,我想了很多办法都没能解决,只有通过图片背景来实现,但我在stackoverflow看到一方案计较好,记录一下:

代码如下:

 

[html] 
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.     <item>  
  4.       <shape   
  5.         android:shape="rectangle">  
  6.             <solid android:color="#FF0000" />  
  7.             <corners android:radius="30dp"/>  
  8.         </shape>  
  9.    </item>  
  10.   
  11.    <item android:left="30dp"  
  12.         >  
  13.       <shape   
  14.         android:shape="rectangle">  
  15.             <solid android:color="#FF0000" />  
  16.         </shape>  
  17.    </item>  
  18.   
  19. </layer-list>  
现在效果都一样了,android2.3.3效果如下:

 

通过两个层,变相的解决了这个问题,希望对大家有帮助!!!!

最后附上stackoverflow的地址:

 

 

转载于:https://www.cnblogs.com/MMLoveMeMM/articles/4204365.html

转载地址:https://blog.csdn.net/FLY_THINK2012/article/details/101840996 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Android LevelList使用实例
下一篇:Android XML文件使用

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月26日 15时08分13秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

spring boot 与 Ant Design of Vue 实现删除按钮(十八) 2019-04-27
spring boot 与 Ant Design of Vue 实现角色管理布局以及角色的列表(十九) 2019-04-27
spring boot 与 Ant Design of Vue 实现新增角色(二十) 2019-04-27
spring boot 与 Ant Design of Vue 实现修改角色(二十一) 2019-04-27
spring boot 与 Ant Design of Vue 实现删除角色(补二十一) 2019-04-27
spring boot 与 Ant Design of Vue 实现组织管理布局的实现(二十二) 2019-04-27
spring boot 与 Ant Design of Vue 实现左侧组织树(二十三) 2019-04-27
spring boot 与 Ant Design of Vue 实现新增组织(二十四) 2019-04-27
spring boot 与 Ant Design of Vue 实现修改组织(二十五) 2019-04-27
spring boot 与 Ant Design of Vue 实现删除组织(二十六) 2019-04-27
spring boot 与 Ant Design of Vue 实现获取用户列表(二十七) 2019-04-27
spring boot 与 Ant Design of Vue 实现修改用户(二十九) 2019-04-27
spring boot 与 Ant Design of Vue 实现删除用户(三十) 2019-04-27
spring boot 与 Ant Design of Vue 鉴权体系登录的实现(三十一) 2019-04-27
spring boot 与 Ant Design of Vue 鉴权体系获取用户信息的实现(三十二) 2019-04-27
Druid连接池实现自定义场景的多数据库的连接 2019-04-27
CentOs7命令行(静默)的方式安装oracle数据库 2019-04-27
基于VMware安装CentOs7的镜像 2019-04-27
PL/SQL数据库管理工具的使用 2019-04-27
带你玩转属于自己的spring-boot-starter系列(一) 2019-04-27