android - android中的圆形个人资料图片

标签 android rounding profile profile-picture

<分区>

我使用下面的代码在android中制作圆形头像

http://www.androidhub4you.com/2014/10/android-custom-shape-imageview-rounded.html

但是在我的主要 Activity 中我使用了 ListFragment 而不是 Activity

imageViewRound = ImageView)parentView.findViewById(R.id.imageView_round);
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.noimage_square);
imageViewRound.setImageBitmap(icon);

我遇到了这个错误

05-15 12:21:27.359: E/AndroidRuntime(25107): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference

最佳答案

试试这些

 com.androidhub4you.crop.RoundedImageView imageViewRound =(com.androidhub4you.crop.RoundedImageView) parentView.findViewById(R.id.imageView_round);

关于android - android中的圆形个人资料图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30253445/

相关文章:

java - 如何以编程方式绘制 ImageButtons 的 5x5 矩阵?

excel - 为什么 Excel VBA 中的银行家舍入函数会根据小数位数给出不同的结果?

c# - 使用 Math.Round 的舍入问题

paypal - 错误代码 : 11581 - Profile description is invalid in paypal

python - CPU秒数的理解

java - 如何将命名组件注入(inject) Dagger 2 中的子图中?

android - 将 Google Play 游戏与 Firebase 结合使用

java - 所以......我正在尝试替换 SupportFragment 但它在 onCreateView 部分崩溃

c# - .NET:十进制到四舍五入的字符串

groovy - 如何在 Maven 配置文件中将 ${basedir} 属性的反斜杠替换为斜杠