ImageView

2019-10-11  本文已影响0人  Alan龙马

总结
https://www.jianshu.com/p/7d713775df9f

扩大ImageView的点击区域

<ImageView
                android:id="@+id/imvDelete"
                android:layout_centerInParent="true"
                android:layout_alignParentRight="true"
                android:layout_width="@dimen/DIMEN_50dp"
                android:layout_height="@dimen/DIMEN_50dp"
                android:scaleType="centerInside"
                android:src="@drawable/icon_toolbar_delete_light" />
代码
设置背景图
imvWeChat.setBackgroundResource(R.drawable.wechat_alreadybound);

xml 中
本地图片用 background
网络图片用 src

图片适配 ScaleType

centerCrop (图片太大,取中间部分)
android:scaleType="centerCrop"
<ImageView
    android:id="@+id/imvIcon"
    android:layout_width="@dimen/DIMEN_40dp"
    android:layout_height="@dimen/DIMEN_40dp"
    android:src="@drawable/icon_avatar_male"
    android:layout_marginLeft="@dimen/DIMEN_15dp"
    android:layout_gravity="center_vertical"
    />

//图片圆角
<com.makeramen.roundedimageview.RoundedImageView
    android:id="@+id/imvIcon1"
    android:layout_width="@dimen/DIMEN_40dp"
    android:layout_height="@dimen/DIMEN_40dp"
    android:background="@drawable/icon_avatar_male"
    android:layout_marginLeft="@dimen/DIMEN_15dp"
    android:layout_gravity="center_vertical"
    app:riv_corner_radius="@dimen/DIMEN_20dp"
    app:riv_mutate_background="true"
    />

RoundedImageView
https://github.com/vinc3m1/RoundedImageView
https://blog.csdn.net/shenggaofei/article/details/83793536

上一篇下一篇

猜你喜欢

热点阅读