当前位置: 移动技术网 > IT编程>移动开发>Android > Android使用xml自定义图片实例详解

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

2019年07月24日  | 移动技术网IT编程  | 我要评论

一箱烟多少条,英式装修风格,制霸中场txt下载

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

实现效果图:

白色圆角图片

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>

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网