android - 在drawable中制作一个布局,它有3个相同颜色的边框,一个是不同的
问题描述
实际上,我为我的布局背景制作了一个可绘制的资源文件。我希望我的布局应该有 3 个相同颜色的面和一个不同颜色的面。
在这段代码中,布局的所有面都是红色的。我想要 3 应该有红色和 1 应该有白色。
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke android:color="@color/colorLightRed" android:width="1dp">
</stroke>
</shape>
解决方案
你可以试试这样的。我猜它不是最好的解决方案..
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="-2dp">
<shape>
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="1dp"
android:color="@color/black30">
</stroke>
</shape>
</item>
<item
android:bottom="-2dp"
android:left="-2dp"
android:top="-2dp">
<shape>
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="1dp"
android:color="@color/green">
</stroke>
</shape>
</item>
推荐阅读
- python - 从 hdfs 将 avro 文件加载到 pyspark 数据帧中
- vue.js - 如何向 nuxt.js 项目添加 bulma 扩展?
- node.js - 配置在 aws fargate 中运行的 node.js 应用程序
- php - symfony 4 中的动态表单内容变化
- mysql - TypeScript - mysql - socket.io 在尝试登录失败后重新发出
- c# - 清理串行读取字符串的第一部分
- python-2.7 - Python:如何编码优化问题的解决方案
- javascript - 使用 JavaScript 完全客户端将给定的文本文件字符串分配给变量
- java - org.openqa.selenium.WebDriverException:转发新会话时出错,找不到:Capabilities {acceptInsecureCerts:Firefox 为真
- css - 如何格式化文本中的文本用动画平滑滚动?