RippleDrawable没有结束绘制意见 [英] RippleDrawable NOT drawing over Views

查看:170
本文介绍了RippleDrawable没有结束绘制意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个KenBurnsView并在它的一个ImageView的(只是一个切换按钮)的布局。当我点击该按钮生成波纹,但汲取的KenBurnsView下面。

I have a layout with a KenBurnsView and an ImageView over it (just a toggle button). When I click on the button a Ripple is generated but is drawn below the KenBurnsView.

previously,当我不得不替换到KenBurnsView涟漪的成像图上绘制顶部的ImageView以上。

Previously, when I had an Image view in replacement to the KenBurnsView the Ripple was drawn above the ImageView on the top.

下面是我的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:clickable="true"
    android:orientation="vertical">


    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="@dimen/nav_drawer_header_height">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.flaviofaria.kenburnsview.KenBurnsView
                android:id="@+id/header_cover"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/cover_1" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/header_toggle"
                    android:layout_width="50dp"
                    android:layout_height="30dp"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginBottom="10dp"
                    android:layout_marginRight="10dp"
                    android:padding="10dp"
                    android:src="@drawable/toggle_down" />

            </RelativeLayout>

        </FrameLayout>

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/nav_toggle_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"></RelativeLayout>

</LinearLayout>

这是我的纹波绘制XML:

This is my ripple drawable XML:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@android:color/white"
    android:drawSelectorOnTop="true"> <!-- ripple color -->

</ripple>

这是怎么了加入纹波:

toggle.setBackground(getResources().getDrawable(R.drawable.ripple));

由于它的纹波被drwan的KenBurnsView下面有什么问题?它曾经完美地工作时,有到位的KenBurnsView?

What is the problem because of which the Ripple gets drwan below the KenBurnsView? It used to work perfectly when there was an ImageView in place of the KenBurnsView?

推荐答案

,你可以从自己的code见('的setBackground'),你设置纹​​波为背景这就是为什么它被在背景绘制。

as you can see from your own code ('setBackground') , you're setting the ripple as a BACKGROUND that's why it's being drawn on the background.

在Android API 21 ImageView的添加了这个黑客为纹波的android:drawSelectorOnTop =真正的。但是,你正在使用的库并没有同样的黑客添加到它。

ImageView on android API 21 added this "hack" for the ripple android:drawSelectorOnTop="true". But the library you're using didn't add the same hack to it.

有什么不对本身的code。但是,这种类型的行为不能由Android团队的第三方库得到保障。

There's nothing wrong itself on your code. But this type of behavior cannot be guaranteed by the Android team for 3rd party libraries.

您有几个在这里的选项,将在清洁,努力和表现各不相同:

You have a few of options here that will vary on cleanliness, effort and performance:


  1. 检查ImageView的源$ C ​​$ C,克隆库,添加相同破解它用于纹波ImageView的。它的正常工作后,请一定要拉请求回库。

  2. 包装你的 KenBurnsView 用的FrameLayout,并使用 setForeground 上的FrameLayout设置纹波。

  3. 克隆库,前景绘制添加选项,它(类似于此<一个href=\"http://stackoverflow.com/questions/16787738/how-to-set-foreground-attribute-to-other-non-framelayout-view\">How设置前景色属性其他非的FrameLayout视图)。另外,请一定要拉这个要求居停code回库。

  1. check ImageView source code, clone the library, add the same hack that imageview used on it for the ripple. After it's working fine, make sure to pull request back to the library.
  2. wrap your KenBurnsView with a FrameLayout and set the ripple using setForeground on the FrameLayout.
  3. clone the library, add option to foreground drawable to it (similar to this How to set foreground attribute to other non FrameLayout view). Also make sure to pull request this valueable code back to the library.

这篇关于RippleDrawable没有结束绘制意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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