Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.57 KB

File metadata and controls

46 lines (35 loc) · 1.57 KB

MaskImageView

可很对背景图或前景图显示遮罩效果的ImageView

01

  • 示例
<cn.forward.androids.views.MaskImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:background="@drawable/bg"
    android:clickable="true"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher"
    app:miv_is_ignore_alpha="true"
    app:miv_mask_color="#880000ff"
    app:miv_mask_level="foreground" />

点击查看更多示例代码

  • 相关属性
<!-- 遮罩的层面:背景\前景图-->
<attr name="miv_mask_level" format="enum">
  <enum name="background" value="1"/>
  <enum name="foreground" value="2"/>
</attr>
<!-- 设置了setClickable(true)才生效,默认开启遮罩-->
<attr name="miv_is_show_mask_on_click" format="boolean"/>
<attr name="miv_mask_color" format="color"/>
<!--是否忽略图片的透明度,默认为true,透明部分不显示遮罩 -->
<attr name="miv_is_ignore_alpha" format="boolean"/>
  • 更多

MaskImageView还支持在xml布局文件设置shape和selector,实现点击效果,点击了解更多

PaddingView

《Android自定义View——可在背景图和前景图显示遮罩效果的ImageView》