Java 圆形图像上的高程不工作

Java 圆形图像上的高程不工作,java,android,shadow,Java,Android,Shadow,即使在向视图添加填充后,立面也不起作用,这是相对布局,我还应该为图像视图中的阴影添加什么 简单的方法是在卡片视图中使用textview,然后使用 android:elevation=”“,请参阅如何使用CardView。您可以使用CardView作为相对布局的父布局,并将标高指定给CardView。它将给您的图像视图添加阴影。希望它对你有用 <android.support.v7.widget.CardView android:layout_width="wrap_cont

即使在向视图添加填充后,立面也不起作用,这是相对布局,我还应该为图像视图中的阴影添加什么


简单的方法是在卡片视图中使用textview,然后使用
android:elevation=”“
,请参阅如何使用CardView。

您可以使用CardView作为相对布局的父布局,并将标高指定给CardView。它将给您的图像视图添加阴影。希望它对你有用

  <android.support.v7.widget.CardView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:cardElevation="5dp"
      app:cardCornerRadius="5dp"
      card_view:cardBackgroundColor="@color/colortransperent">
 <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>
 </android.support.v7.widget.CardView>

我使用下面的代码为任何看起来是圆形的
视图添加阴影。对棒棒糖和以上的工作

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

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

最好使用CardView,在CardView中添加RelativeLayout,并用match\u parent填充它

然后使用CardView的“高程”属性

<android.support.v7.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:elevation="5dp">

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

    </android.support.v7.widget.CardView>

这是一个圆形的图像,我正在尝试,但它没有发生。它增加了整个视图的高度,我想要的只是图像。上面已经回答了,仍然有很多!
<android.support.v7.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:elevation="5dp">

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

    </android.support.v7.widget.CardView>
implementation 'com.android.support:cardview-v7:28.0.0'