我有一个带有KenBurnsView和ImageView的布局(只是一个切换按钮)。当我单击该按钮时,会生成一个脉动,但它会绘制在KenBurnsView下面。
以前,当我有一个图像视图替换为KenBurnsView时,在顶部的ImageView上画出了波纹图。
这是我的布局:
<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:
<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));波普尔在KenBurnsView下面的鼓点有什么问题呢?当有一个ImageView代替KenBurnsView时,它过去工作得很好吗?
发布于 2015-05-15 14:40:01
从您自己的代码('setBackground')中可以看到,您正在将波纹设置为一个背景,这就是为什么要在背景上绘制它。
android 21上的ImageView为波纹式的android:drawSelectorOnTop="true"添加了这个“黑客”。但是你使用的库并没有添加相同的黑客。
你的代码本身没有什么问题。但是这种行为不能由第三方库的Android团队来保证。
在这里,您可以选择以下几个选项,这些选项将在清洁、工作和性能方面有所不同:
KenBurnsView包装您的FrameLayout,并在FrameLayout上使用setForeground设置波纹。发布于 2015-05-15 21:38:07
无限的涟漪投射到祖先视图的第一个可用背景上。从承载波动的ImageView中跟踪视图层次结构,您将发现第一个可用的背景是在带有标识符drawer的LinearLayout上。
如果您在包含您的RelativeLayout的ImageView上设置了一个透明的背景,那么第一个可用的背景将呈现在同级视图之上,您将获得所需的效果。
另外要注意的是,RelativeLayout应该用一个FrameLayout来代替,这样就可以用一个更便宜的布局传递来提供同样的效果。
https://stackoverflow.com/questions/30261947
复制相似问题