【发布时间】:2021-05-10 14:14:33
【问题描述】:
您好,我是 java 和 android studio 的新手,并按照一些教程从图库中获取图像并将其显示在圆形图像视图中。
这是我的代码:
private void openImageFrom() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, IMAGE_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IMAGE_CODE && resultCode == RESULT_OK && data != null && data.getData() != null) {
imageUri = data.getData();
avatar.setImageURI(imageUri);
}
}
问题是circleImageView是根据图片移动的。我需要它保持在固定位置。有谁知道可能是什么问题?
我在 module:app: 中使用这个依赖项
implementation 'de.hdodenhof:circleimageview:3.0.1'
这是我的 XML
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0px"
android:src="@drawable/profile_avatar"
app:civ_border_color="@color/DarkGreen"
app:civ_border_overlay="true"
app:civ_border_width="12dp" />
【问题讨论】: