如何为轮廓添加圆形图像&;使用约束布局,在android中添加一个中间带中心的图像视图

如何为轮廓添加圆形图像&;使用约束布局,在android中添加一个中间带中心的图像视图,android,layout,imageview,android-constraintlayout,Android,Layout,Imageview,Android Constraintlayout,我的要求是,我需要添加一个圆圈图像,其中的宽度和高度36dpwidth&height位于中间,为图标添加一个图像视图(宽度和高度包裹内容) 下面是我试图使用约束布局实现的图像 如何使用约束布局实现相同的效果? 感谢您的帮助[![在此输入图像描述][1][1] <RelativeLayout android:id="@+id/rltCustomerAvatar" android:layout_width="40dp"

我的要求是,我需要添加一个圆圈图像,其中的宽度和高度
36dp
width&height位于中间,为图标添加一个图像视图(宽度和高度包裹内容) 下面是我试图使用约束布局实现的图像

如何使用约束布局实现相同的效果? 感谢您的帮助[![在此输入图像描述][1][1]


 <RelativeLayout
        android:id="@+id/rltCustomerAvatar"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_marginStart="14dp"
        android:background="@drawable/background_circle_highlight"
        android:visibility="@{ customerViewModel.isLoggedIn() ? View.VISIBLE : View.GONE }"
        >
        <ImageView
            android:id="@+id/imgChat"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:layout_marginTop="8dp"
            android:padding="8dp"
            android:scaleType="fitCenter"
            android:src="@drawable/ic_chat_star_page"
            android:layout_centerInParent="true"
            />
    </RelativeLayout>
和背景光

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    >

    <solid android:color="#fb6834"/>

</shape>


在ImageView中使用
background
属性并向其添加轮廓,使用
src
属性添加要在ImageView中显示的图片。无论您使用哪种布局(约束、线性、相对等),这都会起作用。

我正在尝试使用约束布局&圆形应为36 dp&图像应扭曲到中心只需将相对长度更改为约束布局,并将其大小更改为36 dp。并为imageview:app:layout\u constrainttoop\u toTopOf=“parent”app:layout\u constraintBottom\u toBottomOf=“parent”app:layout\u constraintEnd\u toEndOf=“parent”app:layou约束start\u toStartOf=“parent”