簡體   English   中英

選擇圖像后,ImageView沒有顯示圓形

[英]Imageview not showing circular after image is selected

我正在使用Imageview顯示圖像,而我正在使用背景可繪制形狀xml將圖像顯示為圓形。

當我預加載圖像時,它工作正常,但是我設置了Onclick偵聽器,用戶可以在其中編輯和更改用戶個人資料圖片,但是當用戶選擇圖像時,它將顯示矩形圖像視圖而不是回旋。

我該如何解決..

這是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" /> 
和背景形狀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> 

提前致謝。

您可以使用此庫。可以將其用於圓像視圖。很容易。

    <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"

                            />

來源: https : //github.com/hdodenhof/CircleImageView

我想你想要這樣。可以使用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