简体   繁体   English

选择图像后,ImageView没有显示圆形

[英]Imageview not showing circular after image is selected

I'm using Imageview to show images and I"m using background drawable shape xml to show the image in circular shape. 我正在使用Imageview显示图像,而我正在使用背景可绘制形状xml将图像显示为圆形。

It works fine when I preload the image, but I have set Onclick listener where user can edit and change user profile picture but when user selects image then it show rectunglar imageview instead of circulr. 当我预加载图像时,它工作正常,但是我设置了Onclick侦听器,用户可以在其中编辑和更改用户个人资料图片,但是当用户选择图像时,它将显示矩形图像视图而不是回旋。

How can I fixed it.. 我该如何解决..

Here is the xml code 这是XML代码

  <ImageView android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/itemImage1" android:background="@drawable/shape" android:layout_marginLeft="5dp" android:layout_marginBottom="20dp" android:src="@android:drawable/ic_menu_camera" android:cropToPadding="true" android:scaleType="fitXY" /> 
and background shape xml file is 和背景形状xml文件是

 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@color/white"> </solid> <corners android:radius="7dp" > </corners> </shape> 

Thanks in advance. 提前致谢。

You can use this library.ı can use this for circle ımage view.İt is easy. 您可以使用此库。可以将其用于圆像视图。很容易。

    <de.hdodenhof.circleimageview.CircleImageView
                            android:id="@+id/civProfilPicture"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:background="@drawable/ic_camera"

                            />

source: https://github.com/hdodenhof/CircleImageView 来源: https : //github.com/hdodenhof/CircleImageView

I think you want like this.You can use FrameLayout 我想你想要这样。可以使用FrameLayout

  <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:layout_margin="@dimen/small_padding"
    android:orientation="horizontal">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/civProfilPicture"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="@dimen/small_padding"
        android:background="@drawable/ic_profil"
        />

    <ImageView
        android:layout_width="30dp"
        android:layout_height="30dp" 
        android:background="@drawable/ic_edit"

        />

</FrameLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM