海拔不适用于 ImageView [英] Elevation not working for ImageView

查看:16
本文介绍了海拔不适用于 ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ImageView 的高程不起作用.我像这样在 XML 中声明 ImageView:

Elevation for ImageView is not working. I declared ImageView in XML like this:

<ImageView
        android:id="@+id/image"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:elevation="10dp"
        android:src="@drawable/youtube" />

我还应该做什么才能让 ImageView 正常工作?

What else should I do for elevation to work properly for ImageView?

推荐答案

高程阴影来源于View的背景drawable.如果您的 ImageView 没有背景,您将看不到阴影.

The elevation shadow is derived from the background drawable of a View. If your ImageView has no background, you'll see no shadow.

如果你想改变这种行为,你需要构建自己的ViewOutlineProvider 并调用 View.setOutlineProvider() 来设置它(这不是微不足道的).

If you want to change that behavior, you need to build your own ViewOutlineProvider and call View.setOutlineProvider() to set it (and this is not trivial).

这篇关于海拔不适用于 ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆