圆形图片的高程无法唤醒Android

var*_*tia 0 java android shadow

即使在视图中添加了填充后,高程也无法正常工作,这是“相对”布局,我还要在图像视图中添加阴影。在此处输入图片说明

  <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/tvContinueWith"
        android:layout_marginTop="@dimen/_10dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">

        <ImageView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imgFb"
            android:layout_alignParentStart="true"
            android:layout_centerInParent="true"
            android:elevation="@dimen/_5dp"
            android:src="@drawable/fb"
            />

        <ImageView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imgGoogle"
            android:layout_toRightOf="@+id/imgFb"
            android:layout_marginLeft="@dimen/_5dp"
            android:layout_centerInParent="true"
            android:src="@drawable/google"
            android:elevation="@dimen/_5dp"
            />

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Dav*_*idH 5

我使用下面的代码向任何View看起来圆形的阴影添加阴影。适用于棒棒糖及以上。

myCircularImageView.setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setOval(0, 0, view.getWidth(), view.getHeight());
        }
    });
    myCircularImageView.setClipToOutline(true);
Run Code Online (Sandbox Code Playgroud)

我不鼓励使用,CardView因为它会使您的布局更加复杂。