在图像视图上设置波纹效果
2022-09-02 02:54:20
						获得以下图像视图:
<ImageView
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:scaleType="centerCrop"
    app:layout_collapseMode="parallax" 
    android:clickable="true"
    android:focusable="true"
    android:background="?android:attr/selectableItemBackground"/>
如果我没有为图像视图设置位图,则波纹效果很好。但是一旦我设置了这样的位图,涟漪效应就消失了:
ImageView iv=((ImageView)rootView.findViewById(R.id.header));
iv.setImageBitmap(myBitmap);
这是我的涟漪.xml:
<ripple xmlns:android="http://schemas.android.com/apk/res/android" 
                  android:color="?android:colorControlHighlight">
    <item android:id="@android:id/mask">
        <shape android:shape="oval">
            <solid android:color="?android:colorAccent" />
        </shape>
    </item>
</ripple>
我猜位图隐藏了涟漪效应,我怎样才能让它可见?已尝试:
- 将 android:background 更改为 android:foreground,这不起作用。
- 在此之上配置另一个透明图像视图,但由于它是透明的波纹,因此未显示。
有什么想法吗?我也看到Lollipop Contacts也做了这个。
 
					 
				 
				    		 
				    		 
				    		 
				    		