当前位置: 移动技术网 > IT编程>移动开发>Android > Android布局自定义Shap圆形ImageView可以单独设置背景与图片

Android布局自定义Shap圆形ImageView可以单独设置背景与图片

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

好色之图,钦州租房,pdf电子书免费下载

一、图片预览:

一、实现功能:

需求要实现布局中为圆形图片,图片背景与图标分开且合并到一个imageview。

二、具体实现:

xml中布局中定义imageview,关健设置两个参数 android:backgroup(设置背景),android:src(设置imageview中图片),圆形图片制作drawable下定义xml shap样式(solid-color,size-width\hight)

xml代码如下:

<imageview
android:id="@+id/zhongjie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/popwindow_zhongjie"
android:scaletype="centerinside"
android:src="@drawable/mark_caller_house_agent" /> 

drawable-样式xml如下:

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:uselevel="false">
<solid android:color="#66cc00"/>
<size android:width="50dp"
android:height="50dp"/>
</shape>

通过以上内容给大家介绍了android布局自定义shap圆形imageview可以单独设置背景与图片的相关知识,希望对大家今后的工作学习有所帮助。

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

相关文章:

验证码:
移动技术网