【发布时间】:2015-11-03 14:15:06
【问题描述】:
我正在尝试在 API 22 上的 RelativeLayout 中实现涟漪效应,但它没有出现。然而,同样的涟漪在 Button 中起作用。
我的ripple drawable代码如下:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#d1c4e9">
<item android:id="@android:id/mask"
android:drawable="@android:color/white" />
<item android:drawable="@drawable/rect"/>
</ripple>
相对布局代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/ripple">
</RelativeLayout>
在此之后,波纹被设置为Button 和RelativeLayout 的背景。按钮上的波纹效果很好,但它根本没有出现在 RelativeLayout 上。
谁能告诉我我做错了什么?
【问题讨论】:
-
这个波纹对象类是从哪里来的?
-
drawable-v21中的drawable吗?
-
福尔摩斯:抱歉,我没听懂你的问题?
-
Raghunandan:是的,它在 drawable-v21 中,非常适合按钮,但不适用于相对布局
-
@VarunKumar 点击
RelativeLayout会发生什么。你还有其他孩子的观点吗?发布您的相对布局代码。 xml。让我们看看我们是否可以重现您的问题
标签: android button android-relativelayout rippledrawable