【问题标题】:Selecting photo from gallery for CircleImageView从图库中为 CircleImageView 选择照片
【发布时间】: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" />

【问题讨论】:

    标签: java gallery


    【解决方案1】:

    woops 解决了我自己的问题,没关系。

    更改的 XML:

    android:layout_width="350dp"
    android:layout_height="350dp"
    

    【讨论】:

      猜你喜欢
      • 2020-10-02
      • 1970-01-01
      • 1970-01-01
      • 2012-03-21
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多