即使在向 View 添加填充后,标高也不起作用,这是相对布局,我还应该为 ImageView 中的阴影添加什么。
<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>
最佳答案
我使用下面的代码为任何看起来呈圆形的View
添加阴影。适用于 Lollipop 及以上版本。
myCircularImageView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, view.getWidth(), view.getHeight());
}
});
myCircularImageView.setClipToOutline(true);
我不鼓励使用 CardView
因为它会使您的布局更加复杂。
关于java - Android 上圆形图像的高程不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53444332/