Mic*_*idt 4 android background textview android-imageview rippledrawable
我想以编程方式设置TextView对象的背景,但也会产生连锁反应.
我可以使用背景设置android:selectableItemBackground,但设置背景时涟漪效果会丢失.
我也试过把一个ImageView与一起TextView的FrameLayout.并且将图像设置为不是背景TextView,而是将图像设置为ImageView:是的,纹波在那里,但它似乎在图像的"后面".
我是否需要RippleDrawable从背景位图创建一个?我该怎么办?
我和你有同样的问题,并
android:foreground="?attr/selectableItemBackground"在FrameLayout上使用它修复它.
以下是FrameLayout示例:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/more"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:foreground="?attr/selectableItemBackground">
<ImageView
android:id="@+id/discover_carousel_item_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:scaleType="fitXY" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)