高程不适用于ImageView [英] Elevation not working for ImageView

查看:97
本文介绍了高程不适用于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的背景可绘制对象派生的。如果您的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天全站免登陆