位置: 编程技术 - 正文
推荐整理分享Android 圆角图片(android 圆形图片),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:android 图片圆角处理,android设置圆角,安卓圆角图标,android设置圆角,androiddialog圆角,android圆角图片,android 圆角imageview,android圆角图片,内容如对您有帮助,希望把文章链接给更多的朋友!
Android 圆角图片
import android.app.Activity;import android.app.AlertDialog;import android.content.BroadcastReceiver;import android.content.Context;import android.content.DialogInterface;import android.content.Intent;import android.content.IntentFilter;import android.content.SharedPreferences;import android.content.SharedPreferences.Editor;import android.graphics.Bitmap;import android.graphics.Bitmap.Config;import android.graphics.Canvas;import android.graphics.Paint;import android.graphics.PorterDuff.Mode;import android.graphics.PorterDuffXfermode;import android.graphics.Rect;import android.graphics.RectF;import android.graphics.drawable.BitmapDrawable;import android.graphics.drawable.Drawable;import android.os.Bundle;import android.telephony.TelephonyManager;import android.view.KeyEvent;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ImageView;import android.widget.Toast;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); yuanjiaotupian(); } private void yuanjiaotupian() { // TODO Auto-generated method stub ImageView iv = (ImageView) findViewById(R.id.iv_main_yuanjiao); Drawable drawable = getResources().getDrawable(R.drawable.asd); BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); BitmapDrawable bd = new BitmapDrawable(toRoundCorner(bitmap, )); iv.setBackgroundDrawable(bd); } /** * 获取圆角位图的方法 * * @param bitmap * 需要转化成圆角的位图 * @param pixels * 圆角的度数,数越大,圆角越大 * @return 处理后的圆角位图 */ public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_); Canvas canvas = new Canvas(output); final int color = 0xff; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }}
android设备信息获取 android设备信息获取权限:uses-permissionandroid:name=android.permission.READ_PHONE_STATE/importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.content.BroadcastReceiver;impor
android 实现摇一摇功能 实现摇一摇功能,其实很简单,就是检测手机的重力感应,具体实现代码如下:一、在AndroidManifest.xml中添加操作权限uses-permissionandroid:name=android.permission
Android基础系列-----------Android系统框架 Android系统是有众多的子项目组成的。从编程语言角度来看,这些项目主要是使用Java和C/C来实现的;从整体系统框架而言,分成内核层、硬件抽象层、系
标签: android 圆形图片
本文链接地址:https://www.jiuchutong.com/biancheng/381023.html 转载请保留说明!下一篇:android设备信息获取(android 设备信息)
友情链接: 武汉网站建设