Android布局自定義Shap圓形ImageView,可以單獨設置背景與圖片


一、圖片預覽:
                 
 

 

一、實現功能:

   需求要實現布局中為圓形圖片,圖片背景與圖標分開且合並到一個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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM