源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android使用xml自定义图片实例详解

  • 时间:2022-10-13 16:40 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android使用xml自定义图片实例详解
[b]Android使用xml自定义图片实例详解[/b] [b]实现效果图:[/b] [img]http://files.jb51.net/file_images/article/201705/2017525160839900.jpg?201742516850[/img] 白色圆角图片 bg_round_rectangle_white.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">

 <!-- 填充 -->
 <solid android:color="#FFFFFF" />

 <!-- 圆角 -->
 <corners
  android:radius="2dp"/>

 <!-- 描边 -->
 <stroke
  android:width="1dp"
  android:color="#D5D5D5"/>

</shape>

白色圆角虚线框 bg_round_rectangle_white_dash.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">

 <!-- 填充 -->
 <solid android:color="#FFFFFF" />

 <!-- 圆角 -->
 <corners
  android:radius="2dp"/>

 <!-- 虚线描边 -->
 <stroke
  android:width="1dp"
  android:color="#DD4041"
  android:dashWidth="1dp"
  android:dashGap="2dp"/>

</shape>

红色圆角图片 bg_round_rectangle_red.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">

 <!-- 填充 -->
 <solid android:color="#F15C5D" />

 <!-- 圆角 -->
 <corners
  android:radius="2dp"/>

 <!-- 描边 -->
 <stroke
  android:width="1dp"
  android:color="#D42D2E"/>

</shape>

绿色圆角图片 bg_round_rectangle_green.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">

 <!-- 填充 -->
 <solid android:color="#88C14E" />

 <!-- 圆角 -->
 <corners
  android:radius="2dp"/>

 <!-- 描边 -->
 <stroke
  android:width="1dp"
  android:color="#6FA13C"/>

</shape>

正三角形图片 triangle_white_arrow_up.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromDegrees="45"
 android:toDegrees="45"
 android:pivotX="-40%"
 android:pivotY="80%">

 <shape android:shape="rectangle">
  <solid android:color="#000000"/>
 </shape>

</rotate>

倒立正三角形图片 triangle_white_arrow_down.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:fromDegrees="45"
 android:toDegrees="45"
 android:pivotX="135%"
 android:pivotY="15%">

 <shape android:shape="rectangle">
  <solid android:color="#000000"/>
 </shape>

</rotate>

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部