Android图片圆角转换 RoundedImageView开源项目 小记,android逆向工程师

本文介绍了如何在Android中实现图片圆角效果,通过自定义的RoundedImageView组件,设置圆角半径、边框宽度和颜色等属性。详细解析了源码中的关键方法和属性,包括ScaleType、CornerRadius、BorderWidth等。
摘要由CSDN通过智能技术生成

android:paddingLeft=“8dp”

android:paddingRight=“8dp”

android:textAppearance="?android:attr/textAppearanceMediumInverse" />

<TextView

android:id="@+id/textView1"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_above="@+id/textView2"

android:layout_alignLeft="@+id/textView2"

android:layout_marginBottom=“4dp”

android:background="#7f000000"

android:paddingLeft=“8dp”

android:paddingRight=“8dp”

android:textAppearance="?android:attr/textAppearanceLargeInverse" />

如下图:

用代码创建 :

RoundedImageView iv = new RoundedImageView(context);

iv.setScaleType(ScaleType.CENTER_CROP);

iv.setCornerRadius(10);

iv.setBorderWidth(2);

iv.setBorderColor(Color.DKGRAY);

iv.setRoundedBackground(true);

iv.setImageDrawable(drawable);

iv.setBackground(backgroundDrawable);

iv.setOval(true);

贴上部分源码:

package com.makeramen;

import android.content.Context;

import android.content.res.ColorStateList;

import android.content.res.Resources;

import android.content.res.TypedArray;

import android.graphics.Bitmap;

import android.graphics.drawable.Drawable;

import android.graphics.drawable.LayerDrawable;

import android.net.Uri;

import android.util.AttributeSet;

import android.util.Log;

import android.widget.ImageView;

@SuppressWarnings(“UnusedDeclaration”)

public class RoundedImageView extends ImageView {

public static final String TAG = “RoundedImageView”;

public static final float DEFAULT_RADIUS = 0f;

public static fi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值